VMware Cloud Community
FredSOSSON
Contributor
Contributor

DRS Groups interaction

Hello,

I would like to get lists of the VMs being in DRS Groups (ESXi 5.0).

Does anybody have already written something to get that kind of information?

Thank you,

0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership

Hi,

Welcome to the VMware VMTN Communities.

You can use the following PowerCLI script to get a list of all your clusters, VM Drs groups and VM's in this groups:

& {ForEach ($Cluster in (Get-Cluster)) {
      $Cluster.ExtensionData.ConfigurationEx.Group |
      Where-Object {$_.GetType().Name -eq "ClusterVmGroup"} |
      ForEach-Object {
        if ($_)
        {
          $DrsGroup = $_
          Get-View $DrsGroup.Vm |
          ForEach-Object {
            New-Object -TypeName PSOBject -Property @{
              Cluster = $Cluster
              DrsGroup = $DrsGroup.Name
              VM = $_.Name
            }
          }
        }
      }
    }
  }

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
FredSOSSON
Contributor
Contributor

This is the kind of code I was looking for.

Thank you very much.

0 Kudos