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