Can you provide an example for capturing, for system documentation purposes, the DRS rules for cluster?
Thanks,
The following script lists for all cluster all rules and for each rule the guests involved.
Get-Cluster | %{Get-View $_.ID} | %{ $confEx = $_.ConfigurationEx if($confEx.Rule -is [array]){ foreach($rule in $confEx.Rule){ Write-Host "Rule : " $rule.Name "/Enabled : " $rule.Enabled foreach($vmMoref in $rule.Vm){ $vm = Get-View $vmMoref Write-Host "VM : " $vm.Name } } } }
The script uses the ClusterConfigInfoEx object to get to the rules.
Note that the API v2.5 advises to use this object instead of the ClusterConfigInfo object.
The test if($confEx.Rule -is [array]) avoids running through the loop when there are no rules defined.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I would start simply with Get-Cluster. What are you looking for in addition to this?
45# "administrator" | Get-VIServer vcenter 46# Get-Cluster Name HAEnabled HAFailover DRSEnabled DRSMode Level ---- --------- ---------- ---------- ------- HA-Cluster False 1 True Manual
Hal Rottenberg
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Affinity, anti-affinity rules.
The following script lists for all cluster all rules and for each rule the guests involved.
Get-Cluster | %{Get-View $_.ID} | %{ $confEx = $_.ConfigurationEx if($confEx.Rule -is [array]){ foreach($rule in $confEx.Rule){ Write-Host "Rule : " $rule.Name "/Enabled : " $rule.Enabled foreach($vmMoref in $rule.Vm){ $vm = Get-View $vmMoref Write-Host "VM : " $vm.Name } } } }
The script uses the ClusterConfigInfoEx object to get to the rules.
Note that the API v2.5 advises to use this object instead of the ClusterConfigInfo object.
The test if($confEx.Rule -is [array]) avoids running through the loop when there are no rules defined.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you