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.