I am planning to write a PowerCLI script to do cold-migrate of VMs. Move-VM will fail
if a VM is not completely powered off.
My script looks something like this:
------------
$vm = get-vm $vmname
if ($vm.PowerState -eq "PoweredOn") {
Shutdown-VMGuest -VM $vm.Name
}
<Check guest OS or VM state here>
Move-VM -Destination $newhost
--------------
I can call get-vmguest to check the state of the OS. But OS shutdown takes time.
I don't want to keep calling get-vmguest every minute, for example. What is the
correct or better way to assess the VM state before I call Move-VM?
Thanks!