Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 244951

Re: Restart-VMHost doesn't work after disconnect from vCenter

$
0
0

I made a few small changes which avoids the use of the VMHost and VM objects alltogether.

Does this still produce the same errors ?

 

$SleepTimeOut=300
Connect-VIServer-server'vCenter'-username'vickie'-password'abcd'
$hostlist=Get-VMHost|Select-ExpandPropertyName
Disconnect-VIServer
*-confirm:$false
Connect-VIserver
-server$hostlist-user'root'-password'1234'
$vmlist
=get-VM|Select-ExcludePropertyName
Foreach
($virnin$vmlist){  write-host"Shutting down $virn"-BackgroundColorblue-ForegroundColorWhite
  $virn|Shutdown-VMGuest-Confirm:$false
}
sleep10

write-host
"point1"
Disconnect-VIServer
*-confirm:$falseforeach ($pathin$hostlist) {  Connect-VIserver-server$path-user'root'-password'1234'
 
Restart-VMHost$path-RunAsync-force-Confirm:$false
 
write-host"Restarting $path"-BackgroundColorblue-ForegroundColorWhite
 
Disconnect-VIServer*-Confirm:$false
}
write-host"Waiting for hosts to come online(This will take 10 - 15 minutes)..... .  ."-BackgroundColorblue-ForegroundColorWhitesleep$SleepTimeOutif(Test-Connection-ComputerName$path-Count4-easilentlycontinue) {  write-host"Hosts are online. Continue with Syslog firewall enable."-BackgroundColorblue-ForegroundColorWhite
  #configure syslog firewall} elsewrite-host"Hosts unavailable, please check UCS"-BackgroundColorred-ForegroundColorWhite
 
#exit the script}foreach ($string1in$hostlist) {  Connect-VIserver$string1-user'root'-password'1234'
 
ForEach ($vmsinGet-VM) {    write-host"starting up $vm"
   
Start-VM$vms
  } }

Viewing all articles
Browse latest Browse all 244951

Trending Articles



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