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)
Jody Whitlock says
Very interesting and great article, as usual! Honestly haven't found a use for this DRS Score yet, but keep looking at it nevertheless.
Shridhar says
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)