Script to check if VMs part of DRS-Groups

Recently I needed to check, if every VM of a cluster is part of at least one DRS-VM-Group. Typically this is a useful check if you operate a two (or more) site datacenter and/or stretched cluster. You then create DRS-groups for VMs and hosts. For each site a host- and at least a VM-group. At creation time of groups, every VM will be added to a VM-group. But for every new VM, you have to put it to a VM-group manually.

This simple PowerCLI script checks every VM of every cluster if it is part of any DRS-VM-group of its cluster. If not, it will be listed.

foreach ($Cluster in Get-Cluster) {
    Write-Host "`n"
    Write-Host $Cluster.Name
    $ClusterVMs = ($Cluster | Get-VM)
    $GroupVMs = $null
    foreach ($DrsGroup in ($Cluster | Get-DrsClusterGroup)) {
        $GroupVMs = $GroupVMs + $DrsGroup.Member
    foreach ($VM in $ClusterVMs) {
        if ($VM -notin $GroupVMs) {Write-Host "`t" $}


To List all DRS-VM-groups, that contain a specific VM, run: Get-DrsClusterGroup -vm VM-name

Leave a Reply

Your email address will not be published. Required fields are marked *