how to pass performance counters to SCOM Retrieve Performance Data Rest API?

Udesh Chathuranga Sendanayake 1 Reputation point
2020-11-13T17:04:10.227+00:00

Hi,

I'm trying SCOM Retrieve Performance Data Rest API but I'm unable to pass performance counters as it's unclear in their official documentation.

https://learn.microsoft.com/en-us/rest/api/operationsmanager/data/retrieve%20performance%20data

Example :-

## Get performances for the given server  



 $myObject = [PSCustomObject]@{  
objectname = 'Memory'  
countername = 'Available MBytes'  
}   
  $uriPerf = "http://$MS/OperationsManager/data/performance"  
    $perfFilter = @"  
    {  
        "duration": 100,  
        "id": "103c21b9-1dd1-e6ff-ede8-1091e0111abc",  
        "peformanceCounters":[$myObject]  
          
    }"@  
  
  
    $PerfResponse = Invoke-WebRequest `  
        -Method POST `  
        -Uri $uriPerf `  
        -Body $perfFilter `  
        -Headers $scomHeaders `  
        -Credential $cred `  
        -WebSession $websession `  
        #-AllowUnencryptedAuthentication  

    $perf = ConvertFrom-Json -InputObject $PerfResponse.Content  

    Write-Host "Timestamp after get all get performance data for $($server.id) call $(Get-Date)"  
    Write-Host "----------------"   

This is the error I'm getting

 Invoke-WebRequest : {"errorMessage":"Passed parameter cannot be null","errorTrace":""}   
Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,413 questions
0 comments No comments
{count} votes