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

DRS cluster - rolling reboot of esxi

$
0
0

Hi LucD

 

Looking for a script for - DRS cluster - rolling reboot of esxi

 

I did see 1 script

 

 

 

PowerCLI Script For vSphere Cluster Rolling Reboot | Infrastructure Adventures

 

But i wanted to check if you have something too ? ( Industry standard for container orchestration is K8s, for powerli it is LucD

 

 

Pls confirm this will work on all version of any improvemnmet since esxi 4x when you published it

 

$clusterName = <clustername>

$rebootMax = 2

 

 

$targets = @{}

$rebooting = @{}

 

 

Get-Cluster -Name $clusterName | Get-VMHost | %{

$targets[$_.Name] = $_

}

$esxNr = $targets.Count

 

 

while($targets.Count -gt 0){

while($rebooting.Count -le $rebootMax -and $targets.Count -gt 0){

$waiting = $targets.Values | %{$_}

$waiting | Select -First 1 | %{

Set-VMHost -VMHost $_ -State "Maintenance" | Restart-VMHost -RunAsync -Confirm:$false -WhatIf

$targets.Remove($_.Name)

$rebooting[$_.Name] = $_

}

}

sleep 10

while($rebooting.Count -eq $rebootMax -or ($rebooting.Count -ne 0 -and $targets.Count -eq 0)){

$active = $rebooting.Values | %{$_}

$active | %{

$esx = $_

if($esx.State -eq "Maintenance"){

Set-VMHost -VMHost $esx -State "Connected"

$rebooting.Remove($esx.Name)

}

}

sleep 10

}

}


Viewing all articles
Browse latest Browse all 16717

Latest Images

Trending Articles



Latest Images

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