There has been a number of questions about the command notification channel in Technet forums. Here is a example how to configure a command notification channel, a subscriber for the channel and a subscription. This example configure a command notification channel to run a vbscript. The vbscript echo a time stamp and the alertname to a local file.
1. Go to Administration/Notification/Channels and create a new command notification channel. For example
Channel name: Contoso Command Notification Channel
Full path of the command file: C:\windows\system32\cmd.exe
Command line paramters: /c C:\logfile.vbs $Data/Context/DataItem/AlertName$
Startup folder for the command line: C:\
2. Go to Subscribers and create a new subscriber
Subscriber name: Contoso Command Line Subscriber (note that you do not need to select a AD user)
Schedule: Always send notification
Addresses: Added a new address
-Address name: Contoso Command Address
-Channel type: Command
-Command Channel: Contoso Command Notification Channel
-Delivery address for the selected channel: I just left this with default, something about sip: but it resultet in a blank field, so just leave it
-Schedule: Always send notification
3. Goto Subscriptions and add a new subscription, for example
Name: Contoso Command Line Subscription
Criteria: with a specific resolution state: new(0) and closed (255)
Subscribers: Contoso Command Line Subscriber
Channel: Contoso Command Notification Channel
Summary: Make sure the channel is enabled
Thats it, and the logfile.vbs looks like:
' ******************************************
' GET PARAMETERS INTO SCRIPT
' ******************************************
strAlert = Wscript.Arguments.Item(0)
' ******************************************
' LOG TO FILE (DATE,TIME,TO,ALERT NAME,STATE
' ******************************************
Dim Stuff, myFSO, WriteStuff, dateStamp
strdateStamp = Date()
strTimeStamp = Time()
'Write information to Text File
Stuff = strDateStamp & "," & strTimeStamp & "," & strAlert
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile("opsmgr_notification_logfile.txt", 8, True)
WriteStuff.WriteLine(Stuff)
WriteStuff.Close
More info about command notification channel here.

Meanwhile I found the problem (but no solution :d). I added some logging into my vbs code. I am using AT commands to send an SMS, more specific the sendkey method. When I ask the vbs to create a txt file after each line of code (example: cmd.txt, telnet.txt, sms.txt), the script creates this txt files.
However, when you execute manually the VBS file, the focus is within the cmd / telnet session and writes the sended keys. But what happens in SCOM ? Where are the keys send to ? I guess not to the activated cmd/telnet. That’s my problem, now finding the solution …
Hereby the script I used:
Set oShell = CreateObject(“WScript.Shell”)
set WshShell = WScript.CreateObject(“WScript.Shell”)
oShell.run”cmd.exe”
WScript.Sleep 500
oShell.SendKeys”telnet 10.1.1.208 5000″
oShell.SendKeys(“{Enter}”)
WScript.Sleep 1000
oShell.SendKeys”admin”
oShell.SendKeys(“{Enter}”)
WScript.Sleep 1000
oShell.SendKeys”admin”
oShell.SendKeys(“{Enter}”)
WScript.Sleep 1000
oShell.SendKeys”AT”
oShell.Sendkeys (“{ENTER}”)
WScript.Sleep 5000
oshell.SendKeys “AT” & Chr(13)
WScript.Sleep 10000
oShell.SendKeys “AT” & (“{+}”) & “CMGS” & (“{=}”) & “+xxxxxxxx”
WScript.Sleep 10000
oShell.SendKeys “{Enter}”
WScript.Sleep 10000
oShell.SendKeys “test scom”
WScript.Sleep 10000
oShell.SendKeys “^(Z)”
WScript.Sleep 15000
oShell.run”taskkill /F /IM telnet.exe”
WScript.Sleep 5000
Wscript.Quit
try add the cscript.exe as the command starting sms.vbs. You can see in my example how I did with a vbs file from a notification channel.
I exactly implemented the same config, when I change the command line parameters to /c ipconfig>c:\test.txt it write a text file, but when I change the command line paramaters to /c C:\sms.vbs it doesn’t do anything at all, however when I manually enter
C:\windows\system32\cmd.exe /c C:\sms.vbs
it works … any idea ?
the RMS, and outside of Ops Mgr.
Where does the executable or script reside? In the RMS or MS or Gateway?
I think you need to use “” around the paramter, for example “$Data/Context/DataItem/AlertDescription$”
This script works great…except when I run it, it only takes the first word from the Alert?
It appears as though the following detects a space in the variable…which causes it to only log the single word to the log file…has anybody else seen this behaviour?
Wscript.Arguments.Item(0)
You could try C:\windows\system32\cmd.exe as command and then C:\windows\system32\windowspowershell\v1.0\powershell.exe C:\PutScriptMode.ps1 as parameter.
Hi Anders,
How can i get this to run a powershell script? I can get your VBscript to run but not powershell.
i’ve got
C:\Windows\sytem32\windowspowershell\v1.0\powershell.exe in the full path of command
then
C:\PutNodeInPatchMaint.ps1 in the Paramters
and
C:\in startup folder but the powershell script never get executed.
if i run
C:\Windows\sytem32\windowspowershell\v1.0\powershell.exe c:\PutNodeInPatchMaint.ps1
the script works so i know the script is ok.
any ideas?
If anyone is interested, I have a blog enter on how to ‘Forward Ops Mgr Alerts via an SNMP Trap’ via the Command Notification in SP1 & R2.
http://systemcenterspartan.wordpress.com/2009/06/30/forwarding-opsmgr-alerts-snmp/
Cheers,
System Center Spartan