Managing the VM state involves stopping and starting or pausing and resuming a VM. You can also save and restore a VM.
This recipe uses the VM1
VM created in the Creating a virtual machine recipe. This recipe assumes the VM1
VM is stopped when you start this recipe. If this VM is running, then first stop it using Stop-VM
.
Here is how to manage VM state:
- Get the VM's state to check if it is off:
Get-VM -Name VM1
- 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 VM1
Get-Vm -VMName VM1
Wait-VM -VMName VM1 -For IPAddress
Get-VM -VMName VM1
- Suspend and resume a VM:
Suspend-VM -VMName VM1
Get-VM -VMName VM1
Resume-VM -VMName VM1
Get-VM -VMName VM1
- Save the VM and check status:
Save-VM -VMName VM1
Get-VM -VMName VM1
- Resume the saved VM and view the...