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
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
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
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 | %{ <<<<
-
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
Yes, and Yes.
We just have one cluster with 3 esx hosts.
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
That's it! Thank you much LucD!!
Skark166