WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Retrieving VM DRS Score using vSphere API and PowerCLI

Retrieving VM DRS Score using vSphere API and PowerCLI

01.27.2022 by William Lam // 2 Comments

VM DRS Score is a new feature that was introduced with the release of vSphere 7.0, check out this blog post by Niels for a closer look at how this feature can benefit your environment.


In the vSphere UI, this information is expressed as both a Cluster DRS Score and a VM DRS Score as shown in the screenshot above.

This information can also be retrieved programmatically using the vSphere API, as alluded in the title of this blog post. Using the vSphere API, there is a new property called SummaryEx under the ClusterComputeResource object which represents a vSphere Cluster from an API point of view. Here, you will find two new properties: drsScore and numVmsPerDrsScoreBucket which maps to the respective information found within the vSphere UI.

To demonstrate how to access these two new properties, below is a small PowerCLI function called Get-DRSScore which uses the vSphere API to retrieve this information and accepts a single parameter which is a vSphere Cluster object by using the Get-Cluster cmdlet.

Function Get-DRSScore {
    param(
        [Parameter(Mandatory=$true)][VMware.VimAutomation.ViCore.Impl.V1.Inventory.ComputeResourceImpl]$Cluster
    )

    $drsScoreBuckets = @("0%-20%","21%-40%","41%-60%","61%-80%","81%-100%")

    $drsScoreResults = $Cluster.ExtensionData.SummaryEx | select DrsScore, NumVmsPerDrsScoreBucket

    Write-Host "Cluster DRS Score: $(${drsScoreResults}.DrsScore)`n"

    Write-Host "VM DRS Score"
    $count = 0
    foreach($i in ${drsScoreBuckets}) {
        Write-Host "${i} - $(${drsScoreResults}.NumVmsPerDrsScoreBucket[$count]) VMs"
        $count++
    }
    Write-Host
}

Here is an example of using the function and the output matches what is shown in the vSphere UI.

Get-DRSScore -Cluster (Get-Cluster Cluster-1)

More from my site

  • Quick Tip - Retrieving vSAN File Share Network Permissions using vSAN API & PowerCLI
  • Quick Tip - Using PowerCLI to query VMware Tools Configuration at scale 
  • Quick Tip - vCenter Server Advanced Settings Reference
  • Managing vSAN internet connectivity configuration using the vSAN API
  • Downgrading new VMware vSphere Foundation (VVF) or VMware Cloud Foundation (VCF) licenses to 7.x

Categories // Automation, vSphere 7.0 Tags // drs, PowerCLI, vSphere 7.0

Comments

  1. *protectedJody Whitlock says

    01/27/2022 at 12:55 pm

    Very interesting and great article, as usual! Honestly haven't found a use for this DRS Score yet, but keep looking at it nevertheless.

    Reply
  2. *protectedShridhar says

    07/12/2023 at 10:08 pm

    Hello William,

    This is a great blog, which help is writing a script to the DRS score for all the clusters in a vcenter at once.

    Do you have any script to get the DRS score for a individual vms(all VMs in vcenter)

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...