mgraveney
Contributor
Contributor

Rebooting a VM before proceeding

Hi there,

using the Invoke-VMScript to do something that then requires a reboot (adding to a domain), what i'd like to do is wait till the machine comes back then do another Invoke-VMScript command.

Does anyone have a good code snippet that will reliably wait till a vm is back before proceeding?

Thanks in advance

0 Kudos
3 Replies
mattboren
Expert
Expert

Hello, mgraveney-

The new cmdlet Wait-Tools for PowerCLI v4.1 update 1 (changelog) "allows you to wait for VMware Tools of the specified virtual machines to load before proceeding."  So, assuming that you have tools installed on the VM, you should be able to use this cmdlet to achieve the wait.

0 Kudos
LucD
Leadership
Leadership

Be aware that Wait-Tools is not always the ideal point to launch another Invoke-VMScript.

See  VmGuestNetworkInterface Question.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
mattboren
Expert
Expert

Thanks for the additional info/warning, LucD.  So, maybe a Wait-Tools combined with a Start-Sleep for good measure (or a WMI query or something).

0 Kudos