
Graham Davies
Technical Product Manager – SCOM products


Technical Product Manager – SCOM products
A question came up on Community Answers about using the PowerShell Community Management Pack to create performance data for the number of occurrences of a particular event id every 15 minutes. This is a walk through of how this can be achieved.
I have assume have assumed:ed:
Let's go!

3. Enter the Name and description for the rule as well as the target for the rule. In this example I will target Windows Server Operating System and mark the rule disabled and I'll later go back and enable it for a specific server. In practice, I'd create a SCOM class and target the class directly. Your mileage will vary depending on what you are looking to achieve. Click Next.t

4. I've scheduled my script for every minute for testing purposes. The original post was for every 15 minutes. If you do have a short interval, be careful not to overload the server and cause performance issues from over monitoring.

5. Give the Script a name and Paste in the code.

# Any Arguments specified will be sent to the script as a single string.
# If you need to send multiple values, delimit them with a space, semicolon or other separator and then use split.
param([string]$Arguments)
$ScomAPI = New-Object -comObject "MOM.ScriptAPI"
# Collect your performance counter here. Note that in order to support the DW this script MUST only return a single
# object/counter and those must be static values. You can return multiple instances just fine though.
$eventCount = Get-WinEvent -FilterHashtable @{
LogName = 'Application'
ID = 123
StartTime = (Get-Date).AddMinutes(-1)
} | Measure-Object | Select-Object -ExpandProperty Count
$ScomAPI.LogScriptEvent("Event123.ps1",9999,2,"Event Count = " + $eventCount)
$PropertyBag = $ScomAPI.CreatePropertyBag()
$PropertyBag.AddValue("EventCount", $eventCount)
# Send output to SCOM
$PropertyBag
}
6. Configure the Mapping. In the next windows (the Performance Mapper)

7. I'll then go to my rule in Authoring > Management Pack Objects > Rules and enable it for a specific server. I won't describe these steps.
8. I then created a performance view to ensure that the monitoring was working.
Let's test it out ..

2. View the performance chart.
