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):
$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
Startup Folder for the Command Line
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