Managing VM state
Scripting the state of virtual machines allows us to quickly and easily manage all of the virtual machines in your environment. This will allow us to power systems on or off individually, as a group, or as a job that occurs automatically based on the time of day, or triggered by external processes.
Getting ready
In this recipe we will be working with the Accounting02
virtual machine created in the Creating virtual machines recipe.
How to do it...
Carry out the following steps to manage VM state:
View the current virtual machine state:
Get-VM -ComputerName HV01 -Name Accounting02
When executed, you should see a screen similar to the following screenshot:
Power on the virtual machine:
Start-VM -ComputerName HV01 -Name Accounting02
When executed, you can call
Get-VM
again to confirm the change:Suspend the virtual machine:
Save-VM -ComputerName HV01 -Name Accounting02
When executed, you can call
Get-VM
again to confirm the change:Resume the virtual machine:
Start-VM -ComputerName HV01 ...