Powershell script to pull out performance objects, counters and sample count for a specific counter collected by SCOM

The below powershell script extracts the number of samples of a specific performance object and counter in the last 24 hours.

This information can be used to check if the performance data is being collected and can also be input into a run-book in SCORCH to further troubleshoot the counts that comes out to 0.

For this script the objectname for the performance data is ‘Cluster Shared Volume’ and the counter is ‘Free space / Percent’

$managementServer=”management server name here”

import-module OperationsManager

try {$mg = New-Object Microsoft.EnterpriseManagement.ManagementGroup($managementServer)}

catch {

“Could not connect to management server $managementServer”



$starttime = [datetime]::today.addhours(-24)

$endtime = [datetime]::today.adddays(1)

$mpdc = “ObjectName = ‘Cluster Shared Volume’ and CounterName = ‘Free space / Percent'”

$mpds = $mg.GetMonitoringPerformanceDataReader($mpdc)

while ($mpds.read())


$perfdata = $mpds.getmonitoringperformancedata()

#write-host $perfdata.count

$valuereader = $perfdata.getvalues($starttime, $endtime)

$displayname = $perfdata.monitoringobjectdisplayname.tostring()

$path = $perfdata.monitoringobjectpath.tostring()

$count = $valuereader.count.tostring()

write-host “$path, $displayname, $count”

# write-host $perfdata.monitoringobjectpath


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s