Thursday, July 14, 2016

Activate Maintenance Mode for a Host on vCenter Server

To complete some specific administration tasks, you might need to activate maintenance mode for a host. On vCenter Server, you can activate maintenance mode by using the Set-VMHost cmdlet.
Verify that you are connected to a vCenter Server system.
1
Save the Host host object as a variable.
$vmhost = Get-VMHost -Name Host
2
Get the cluster to which Host belongs and save the cluster object as a variable.
$vmhostCluster = Get-Cluster -VMHost $vmhost
3
Start a task that activates maintenance mode for the Host host and save the task object as a variable.
$updateHostTask = Set-VMHost -VMHost $vmhost -State "Maintenance" -RunAsync
Note
If the host is not automated or is partially automated and has powered-on virtual machines running on it, you must use the RunAsync parameter and wait until all powered-on virtual machines are relocated or powered off before applying DRS recommendations.
4
Get and apply the recommendations generated by DRS.
Get-DrsRecommendation -Cluster $vmhostCluster | where {$_.Reason -eq "Host is entering maintenance mode"} | Apply-DrsRecommendation
5
Get the task output object and save it as a variable.
$myUpdatedHost = Wait-Task $updateHostTask

No comments:

Post a Comment

Thanks for showing interest in tech-jockey.

Content of this blog has been moved to GITHUB

Looking at current trends and to make my content more reachable to people, I am moving all the content of my blog https://tech-jockey.blogsp...