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

2015-10-19 12:14:05
Posted by aeadmin on Oct 19, 2015 5:14:05 AM

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

Tags: custom scripts, Servers, Technology, SCCM, system center

    Are You Secure? Score a FREE O365 Security Assessment.

    We're here to help!

    We'd love to find out more about the projects and initiatives you're working on to exchange ideas and provide some high-level guidance where we can.  We love learning from others as well as sharing some of our experience and lessons learned.  Let's talk!

    Subscribe to Email Updates

    Recent Posts

    Posts by Tag

    see all