VMware Cloud Community
Al_
Enthusiast
Enthusiast

Get-VM | Get-OMResource | Get-OMStat -Key | Sort-Object

Attempting to create an array of VMs and sort on custom OMStat -Key/supermetric value fails:

ForEach ($item in $vms2rs) {
$Name = $item.Name
[array]($deltascore = Get-VM -Name $Name | Get-OMResource | Get-OMStat -Key "Super Metric|sm_6dcf4b1d-fa56-4119-bef8-b197df54b70a" -From ([DateTime]::Now).AddMinutes(-120) | Select-Object Resource, Value -Last 1 | Sort-Object -Property Value)
}

Returns:

Resource : ***-rhel79-test
Value : 0


Resource : ******2016test
Value : 5


Resource : ***tstviewcs
Value : 6


Resource : ***tstviewss
Value : 3

 

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Did you check that the Value property is a Scalar?
Do a Get-Member on the objects returned by Get-OMStat


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos