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.
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
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 ...