Sometimes it’s necessary to launch a custom script or other action after an alert is detected. This can be all executable scripts or programs.
In my particular case I’m using this to launch scripts when an alert is detected to properly escalate the alert and perform additional tasks on the alert.
So how do you make sure that the script you intend to run will actually run when a predefined alert is raised?
By creating a Command notification channel and subscription…
Let’s start with setting up the command notification channel.
Note: I’m using my script Create_Ticket.Ps1 as documented here. The parameters I’m passing are useful for this script but you can pass many more parameters according to your needs.
First of all open the Notification Channels by opening the SCOM console > administration > Notifications > Channels
Right click in the Right pane > choose New > Command…
In the settings tab you need to fill in what you prefer to run:
- Full Path of the command file: In my case this is PowerShell as I would like to run a PowerShell script
- Command Line Parameters: In my case I’m running a PowerShell script and I’m passing the AlertID of the specific alert as an argument which I’m using in my script. Again you can use any arguments here if you like.
- Startup folder for the command line: This is basically the path of your program you want to run.
At this point your Command Notification Channel is set up. The next thing you need to configure is the trigger which will run this Command Notification Channel. This is done by creating a Subscriber:
Open the Scom console and navigate to Administration > notifications > Subscribers
Right click in the right pane and choose New…
Fill in a name for the Subscriber
Leave the “always send notifications” or specify a time window (ex. during business hours only) and click next.
Click Add to ad a subscriber address to the list. The following window appears:
Fill in the address name and click next
- Channel Type: Select Command in the drop down list
- Command Channel: Select the previously created Channel in this case it’s “Ticket” from the drop down list.
- Click Next
Leave the always send notifications setting or change according to your needs.
Click Finish and you have configured your Command to run whenever you subscribe to an alert with this channel.