VMware Cloud Community
dloop2
Contributor
Contributor
Jump to solution

Get & Document DRS Rules

Can you provide an example for capturing, for system documentation purposes, the DRS rules for cluster?

Thanks,

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
4 Replies
halr9000
Commander
Commander
Jump to solution

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)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
dloop2
Contributor
Contributor
Jump to solution

Affinity, anti-affinity rules.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
dloop2
Contributor
Contributor
Jump to solution

Thank you

0 Kudos