Hey all,
I was looking for a method to put a vHost into maintenance mode, but first evacuating the VMs using DRS. I am having some issues finding the terms for the second part.
Thanks,
Andy
I think adding the -Evacuate switch to the set-vmhost cmd should move the powered off VMs.
Hi Andy,
Do you want to user DRS? or just move the vm?
Here is a link to the Move-vm cmdlet.
Is your DRS set to automatic mode?
If yes, the VMs should be vMotion-ed when you set the host to maintenance mode with the Set-VMHost cmdlet.
If not, can you set the DRS mode temporarily to FyllyAutomated with the Set-Cluster cmdlet?
$esxName = 'MyESX'
$cluster = Get-Cluster -VMHost $esxName
if($cluster.DrsAutomationLevel -ne 'FullyAutmated'){
Set-Cluster -Cluster $cluster -DrsAutomationLevel FullyAutomated -Confirm:$false
}
Set-VMHost -VMHost $esxName -State Maintenance -Confirm:$false
Or is it something completely different you want to do?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is nearly what I am looking for. It puts the vhost into maintenance mode, but it does not migrate off all VMs (powered off ones included). Is there an additional switch for this?
There can be several reasons for that.
Is the cluster DRS configured with FullyAutomated?
Do the VMs perhaps have ISOs mounted on the CD/DVD devices?
Are there Host-VM affinity rules prohibiting the move?
Is HA admission control enabled?
Is there sufficient capacity on the other nodes in the cluster to host the VMs?
Perhaps show a screenshot of the cluster settings
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I think adding the -Evacuate switch to the set-vmhost cmd should move the powered off VMs.
Good idea Ben, but isn't that switch only for re-registration of powered off VMs?
But definitely a switch you should add.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I've never worried about moving powered off VMs via PowerCLI... Typically I patch via PowerCLI and the VMs migrate via DRS and anything left is unavailable for about 30 minutes at most.
If that doesn't work, going along the route of doing it manually may work too... You'd need to script disabling DRS, moving the VMs, and then setting maintenance mode. Finally, you'll want to re-enable DRS again.
This post from Damian Karlson for way back may get you started.
Ghetto host evacuation: PowerCLI — DAMIAN KARLSON
I already had the clusters setup for Auto for DRS and it worked simply when I told a vhost to manually go into maint mode. I added the -evacuation switch and it worked perfect, both powered on and off VMs moved.
Thanks guys,
Andy