Public/Resume-PVEVM.ps1
|
function Resume-PVEVM { <# .SYNOPSIS Resumes QEMU virtual machines paused with Suspend-PVEVM. .DESCRIPTION Resumes a VM paused in memory. A VM hibernated with Suspend-PVEVM -ToDisk is stopped, not paused; resume that with Start-PVEVM. PVE rejects the request for a VM that is not paused, and that rejection is reported as an error. .PARAMETER Name VM name(s). Wildcards allowed. .PARAMETER VMId VM ID(s). Binds from piped PVEPS.VM objects. .PARAMETER RunAsync Return the PVE task(s) at once instead of waiting. .PARAMETER Server Connection(s) to use. Defaults to the default connection; binds from piped objects. .EXAMPLE Resume-PVEVM web01 #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '', Justification = 'ShouldProcess is called on this cmdlet through $PSCmdlet by Invoke-PVEPowerAction.')] [CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType('PVEPS.VM', 'PVEPS.Task')] param( [Parameter(Mandatory, ParameterSetName = 'Name', Position = 0)] [SupportsWildcards()] [ValidateNotNullOrEmpty()] [string[]]$Name, [Parameter(Mandatory, ParameterSetName = 'Id', ValueFromPipelineByPropertyName)] [ValidateRange(100, 999999999)] [int[]]$VMId, [switch]$RunAsync, [Parameter(ValueFromPipelineByPropertyName)] [Alias('Connection')] [object[]]$Server ) begin { $targets = [System.Collections.Generic.List[psobject]]::new() } process { Add-PVEGuestTarget -Cmdlet $PSCmdlet -Target $targets -Server $Server -VMId $VMId -Name $Name } end { Invoke-PVEPowerAction -Cmdlet $PSCmdlet -Type qemu -Action resume -Description 'Resume' -Target $targets -RequiredStatus any -RunAsync:$RunAsync } } |