Blog - AdaptivEdge

SCOM 2012 Channels and Subscriptions - Adding a Script to Log Alert Descriptions to a File

Written by aeadmin | Oct 19, 2015 12:14:05 PM

Audience – Intermediate Level of Expertise with SCOM

We’ve run across a few clients wanting to save alerts or descriptions to a file. There are a few ways to do this, but we’ll just tackle the process via subscription and channel.


First, create a PowerShell script and save on your management server(s). Save as channelforlogging.ps1 (or whatever name makes sense for you):

Param ([String]$AlertName,[String]$SubscriptionID)

$Logstring = $AlertName + " " + $SubscriptionID

$Logfile = "<share name or local drive>\adminaudit$\LogAlert.log"

$DateTime = Get-Date -Uformat "%y-%m-%d %H:%M:%S"

$Logstring = $DateTime + " " + $Logstring

Add-content $Logfile -value $Logstring

Then, create a new Command Channel (New, Channel, choose Command as the type) with the following settings:

Full Path of Command Line

"<path of script>\channelforlogging.ps1" '$Data/Context/DataItem/AlertDescription$' $MPElement$'

Command Line Parameters

c:\windows\system32\windowspowershell\v1.0\powershell.exe

Startup Folder for the Command Line

c:\windows\system32\windowspowershell\v1.0\

After the Command Channel is created, you can then create a subscription using the channel you’ve created. Then test and adjust as needed.

Written and composed by one of our Senior Microsoft System Center Architects, Jessica Ervin-Hang