I've made that into a function, to exactly that:
function WaitforVM($VM)
{
while (((get-vm $VM ).ExtensionData.Guest.ToolsRunningStatus ) -ne "guestToolsRunning" )
{
Write-Host "Waiting for machine to come back....." -ForegroundColor Yellow
Sleep 5
}
}
Now all you have to do, is to start the VM after the CPU addition, wait, then restart and wait again:
Start-VM -VM $VM -Confirm:$False
WaitforVM -VM $VM
Restart-VMGuest -VM $VM -Confirm:$False
WaitforVM -VM $VM
Nice, right? Obviously this function can be used for other things, like being used in scripts when you create a new VM from template and boot it up to see if that VM is live already.
No comments:
Post a Comment