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 myserver.stresstest.com "Memory" "Available MBytes"
you quickly get a GridView of the requested data, with the requested counter in the title bar.