Showing posts with label restart. Show all posts
Showing posts with label restart. Show all posts

Wednesday, January 25, 2017

Waiting for a VM to come back

In my previous post, I wrote about upgrading vCPU's, and that I want to do several other things as well. If you upgrade a vCPU on a VM, it could very well be that the Windows guest wants a second reboot. I've found that simply rebooting and waiting for a while is inefficient. So I usually check if the VMware tools are back online.

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.

Friday, November 25, 2011

Invalid configuration for device ’0′ when enabling a NIC in vSphere

Suddenly a VM was unreachable on all interfaces. Upon investigation, I saw that none of the NIC's were set to connected:







When I tried to enable them again I got Invalid configuration for device ’0′:




Some googling led to a simple solution, which is to restart the management agents:

service mgmt-vmware restart

and

service vmware-vpxa restart

Good to know. Thanks go to the cupfighters for investigating it deeper and leading me to the answer.