I am trying this script but it is not waiting for the host to be paotched and come back online before putting the second host into maintenance mode.
$baseline = get-baseline -server vc -name "6.5 dynamic"
$vmhosts = get-vmhost (get-content esxhosts.txt)
foreach ($vmhost in $vmhosts){
get-vmhost -name $vmhost | set-vmhost -state maintenance -confirm:$false
scan-inventory -entity $vmhost
$baseline | remediate-inventory -entity $vmhost -confirm:$false -erroraction silentlycontinue
}
any idea why it is putting the second host into maintenance mode before waiting for the 1st host to come back online?
thanks
also it quits after remediating 2 hosts
You will have to build your own wait-loop after each ESXi node's Remediate.
Best is to wait till the ESXi node is back, and fully operational in the cluster, just a test for powered on is not enough most of the time.
Waiting till the vpxa service is running again would be a good test.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am trying this but getting error
$baseline = get-baseline -server vc -name "6.5 dynamic"
$vmhosts = get-vmhost (get-content esxhosts.txt)
foreach ($vmhost in $vmhosts){
$baseline | attach-baseline -entity $vmhost -confirm:$false
get-vmhost -name $vmhost | set-vmhost -state maintenance -confirm:$false
scan-inventory -entity $vmhost
$task = $baseline | remediate-inventory -entity $vmhost -confirm:$false -erroraction silentlycontinue -runasync
while ($task.percentcomplete -ne 100) {
start-sleep 10
$task = get-task -id $task.id
}
}
Did you stop/start your PowerShell/PowerCLI session before the test?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference