Using Powershell to Access SCOM 2007 Performance Data

I’ve been working in a SCOM 2007 R2 implementation project for a while,
and started playing around with the ‘Operations Manager Shell’,
which is basically PowerShell with the SCOM 2007 R2 PowerShell SnapIn and some extra functions loaded.
This post assumes you have an existing connection to a Management Server, created with
the New-ManagementGroupConnection CmdLet for example.
This time I wanted to see how I could get some Performance Data out of SCOM,
so I could always quickly access any collected performance data without logging on to the Graphical Ops Console.
I started fiddling around and doing some discovery on the commands, and came up with following command,
Get-PerformanceCounter | Select-Object MonitoringObjectPath, ObjectName, CounterName | Out-GridView
that displays all available PerformanceCounter instances  (assumes PowerShell v2.0 for Out-Gridview):
You can leave the ‘GridView’ open for ease of the next commands to display Performance values.
I created a basic function that you can use to display Performance Values for any available counter,
starting 7 days ago, and ending 1 day ago (feel free to customize as you like).
Function Get-PerfData ($FQDN,$ObjectName="Processor",$CounterName="% Processor Time")
$criteria= "MonitoringObjectPath=’$FQDN’ AND ObjectName=’$ObjectName’ AND CounterName=’$CounterName’"
$perfcounter =Get-PerformanceCounter  -criteria  $criteria
$perfcounter | Get-PerformanceCountervalue -StartTime $starttime -EndTime $endtime | Select-Object SampleValue,TimeSampled | Out-GridView -Title $Criteria
When you call the Function like this:
Get-PerfData "Memory" "Available MBytes"
you quickly get a GridView of the requested data, with the requested counter in the title bar.

One response to “Using Powershell to Access SCOM 2007 Performance Data

Leave a Reply

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

You are commenting using your 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