Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

Reboot a VM and wait until tools are running before rebooting the next vm

$
0
0

I'm trying to write a script that will reboot a vm and wait until the vm has tools running before the next vm starts the reboot process. Also the reason I used $toolsStatus -ne "toolsNotRunning" instead of $toolsStatus -eq "toolsOK" is because we have a lot of tools that are not current. The reason I want to do this is because I want a script to reboot my Domain Controllers and I don't want the second DC to reboot until the first DC is back up and running. Here is what i have currently however when I run the script the first VM reboots and within 5 seconds the second vm starts to reboot before the first vm is back up and running. Any help would be appreciated.

 

#Connect to the vCenter Server

  Connect-VIServer vcenter.domain.local

#Reboot servers in proper order and wait for tools to be running until the next vm reboots

  $Input = "VMTEST1","VMTEST2"

  foreach ($VM in $input){

  Restart-VM -VM $VM -Confirm:$false

  Do {$toolsStatus = (Get-VM $VM).extensiondata.Guest.ToolsStatus

  write-host $toolsStatus

  sleep 5} until ( $toolsStatus -ne "toolsNotRunning" )}

 

Thanks,

Josh


Viewing all articles
Browse latest Browse all 179681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>