Is the cluster this ESX server is in DRS enabled?

Whilst attempting to create a portion of a script to set up and test VMware’s DPM (Distributed Power Management) I found that I needed to find out which cluster the host was actually in, so that I could then determine if DRS was enabled. If DRS is not enabled it is not possible to place a host into Standby Mode, that option will be greyed out in the vSphere Client. If you can not manually put the host into Standby Mode and Power On again to successfully test DPM the host will not participate in DPM.

#Get the VMHost object
$vmhost = Get-VMHost -name "MyESX"
#Get the Cluster object
$cluster = Get-Cluster | ? { $_.Id -eq $vmhost.ParentId }
#Test the Cluster has DRS enabled
if ( $cluster.DrsEnabled -ne $true ) 
{
  Write-Output "DRS is *NOT* enabled on the cluster $cluster. Please enable DRS on this cluster and try again."
  Return
}

You could also get the True/False value in a one liner, if you felt so inclined and act accordingly:

(Get-Cluster | ? { $_.Id -eq (Get-VMHost -name "MyESX").ParentId }).DrsEnabled

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.