With PowerCLI, you can automate various administration tasks on virtual machines, for example retrieving information, shutting down and powering off virtual machines.
Procedure
- View all virtual machines on the target system.
- Save the name and the power state properties of the virtual machines in the ResourcePool resource pool into a file named myVMProperties.txt.
$respool = Get-ResourcePool ResourcePool
Get-VM -Location $respool | Select-Object Name, PowerState > myVMProperties.txt
- Start the VM virtual machine.
- Get information of the guest OS of the VM virtual machine.
- Shut down the OS of the VM virtual machine.
- Power off the VM virtual machine.
- Move the virtual machine VM from the Host01 host to the Host02 host.
Get-VM -Name VM -Location Host01 | Move-VM –Destination Host02
Note: If the virtual machine you want to move across hosts is powered on, it must be located on a shared storage registered as a datastore on both the original and the new host.