In a PowerCLI script I force a powered off VM to power up.
In a few seconds the PowerState property of the VM changes to "PoweredOn", but I have to wait a quite long time for the boot to complete, till the moment when I see "Press CTRL + ALT + DELETE to log on" and I can logon.
Is there any property or state I can check in order to ensure that the boot process is complete and that I can logon to the VM?
Regards
marius
The answer in this thread may be what you're looking for.
I don't think you can do this via vSphere.
You can query the guest OS to check if it is ready to accept sessions.
This can be done over the network, but also through the Invoke-VMScrip cmdlet.
One way to check if the Windows guest OS is ready is to check if event 100 has fired
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for the pointer.
The suggested code looks very usefull, but while testing it I discovered that $toolsStatus (the value returned by $vm.extensionData.Guest.ToolsStatus) is set properly the first time, but is not updated the following times, so I get an eternal loop.
Is there any way to make the code work, as it is exactrly what I need?
Regards
marius
The ExtensionData object is not automatically updated, you have to ask for an update.
$vm.ExtensionData.UpdateViewData('Guest.ToolsStatus')
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry about that, the answer in the other post wasn't updating the VM status in the loop.
Try like this...slightly different take on status as it will protect against a Tool out of date status - the script does assume VMTools installed.
Start-vm -VM <Name> -runAsync
Start-Sleep -Seconds 20;
$vm = get-vm <name>
$vm | Get-VMQuestion | Set-VMQuestion -DefaultOption -confirm:$false;
do
{
Start-Sleep -Seconds 5;
$toolsRunningStatus = (Get-View $vm).Guest.ToolsRunningStatus;
}while($toolsRunningStatus -ne "guestToolsRunning");