VMware Cloud Community
Skark166
Contributor
Contributor
Jump to solution

How to verify ESX host have DRS Enabled with Powershell

Ok, I've been stumbling arround with this for a while. I'm trying to write a script that will verify our systems are good for HA Failover and DRS. One of the main criteria is that the ESX host has DRS enabled. However, the only properties I can find for DRS is related to the cluster. Is there way to check the DRS Settings on an ESX host via script?

Thanks,

Skark166

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Just noticed, a typo in my script.

Try this:

$esxtgt = <ESX-hostname>
 
Get-Cluster | Get-View | %{
  foreach($h in $_.Host){
    if((Get-View $h).Name -eq $esxtgt){
      Write-Host $esxtgt
      Write-Host "`tDRS enabled : " $_.Configuration.DRSConfig.Enabled
      Write-Host "`tHA enabled  : " $_.Configuration.DasConfig.Enabled
    }
  }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Afaik there is no direct method to find out if a host has HA and/or DRS enabled.

These settings are kept with the cluster.

This script runs through all the hosts, that are in a cluster, for all the clusters to find the target host.

If found the script says if HA and/or DRS are enabled.

$esxtgt = <ESX-hostname>

Get-Cluster | Get-View | %{
  foreach($h in $clus.Host){
    if((Get-View $h).Name -eq $esxtgt){
      Write-Host $esxtgt
      Write-Host "`tDRS enabled : " $_.Configuration.DRSConfig.Enabled
      Write-Host "`tHA enabled  : " $_.Configuration.DasConfig.Enabled
    }
  }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Skark166
Contributor
Contributor
Jump to solution

Hmm...that script isn't working for me, I get a NULL value error...I am a bit of a noob at this stuff tho, perhaps I'm doing something wrong. I entered my ESX Host name for the $esxtgt var and ran.

-


POWERSHELL EXCEPTION

EXCEPTION TYPE:System.Management.Automation.CmdletInvocationException

MESSAGE:The argument cannot be null or empty.

POSITION:

At line:12 char:27

+ Get-Cluster | Get-View | %{ &lt;&lt;&lt;&lt;

-


0 Kudos
LucD
Leadership
Leadership
Jump to solution

Two points to check:

1) You did connect (Connect-VIServer) to your VC ?

2) You do have a cluster in your VI ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Skark166
Contributor
Contributor
Jump to solution

Yes, and Yes.

We just have one cluster with 3 esx hosts.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Just noticed, a typo in my script.

Try this:

$esxtgt = <ESX-hostname>
 
Get-Cluster | Get-View | %{
  foreach($h in $_.Host){
    if((Get-View $h).Name -eq $esxtgt){
      Write-Host $esxtgt
      Write-Host "`tDRS enabled : " $_.Configuration.DRSConfig.Enabled
      Write-Host "`tHA enabled  : " $_.Configuration.DasConfig.Enabled
    }
  }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Skark166
Contributor
Contributor
Jump to solution

That's it! Thank you much LucD!!

Skark166

0 Kudos