Managing VM state
Managing the VM state involves stopping and starting, or pausing and resuming, a VM. You can also save and restore, as shown in this recipe.
Getting ready
This recipe uses the PSDirect
VM created in the Creating a virtual machine recipe. This recipe assumes the PSDirect
VM is stopped when you start this recipe. If this VM is running, then first stop it using the Stop-VM
cmdlet.
How to do it...
Get the VM's state to check if whether is off:
Stop-VM -Name PSDirect -WarningAction SilentlyContinue Get-VM -Name PSDirect
Start the VM, get its status, then wait until the VM has an IP address assigned and the networking stack is working, then examine the VM's state:
Start-VM -VMName PSDirect Wait-VM -VMName PSDirect -For IPAddress Get-VM -VMName PSDirect
Suspend and view the
PSDirect
VM:Suspend-VM -VMName PSDirect Get-VM -VMName PSDirect
Resume the VM:
Resume-VM -VMName PSDirect Get-VM -VMName PSDirect
Save the VM and check its status:
Save-VM -VMName PSDirect Get-VM -VMName PSDirect
Resume...