Using VBscript to send SCOM Notification Alert via SMS Gatway
OK, I have been digging through the forum posts and have seen a lot of interesting things, but unfortunately I'm not able to find and/or fix my specific situation. I am trying to send an SMS message to my mobile phone whenever a Critical Alert fires. The script I use is a VBScript with parts of other scripts in it. One thing it does is open a Telnet session to our SMS Gateway Appliance and send the message via AT commands. The script runs fine when starting from a command line, but nothing happens when the script (should) run(s) from within SCOM 2007 R2. I don't even know if it is actually started at all, even though I've used Anders' explanation for creating the Channel, Subscriber and Subscription. My Command Notification Channel is built up as follows: - Full path: %windir%\system32\cmd.exe - Parameters: /c c:\send_sms.vbs $Data/Context/DataItem/AlertName$ - Startup folder: C:\ The script is built up as follows: 'Script for creating a Telnet session and sending an SMS message via the SMS Gateway ' ****************************************** ' GET PARAMETERS INTO SCRIPT ' ****************************************** Dim strAlert strAlert = Wscript.Arguments.Item(0) ' ****************************************** ' LOG TO VARIABLE (DATE,TIME,TO,ALERT NAME,STATE ' ****************************************** Dim Stuff, dateStamp strdateStamp = Date() strTimeStamp = Time() 'Write information to variable Stuff = strDateStamp & "," & strTimeStamp & "," & strAlert ' START OF SMS SCRIPT Set oShell = CreateObject("WScript.Shell") set WshShell = WScript.CreateObject("WScript.Shell") oShell.run"cmd.exe" WScript.Sleep 500 oShell.SendKeys"telnet -t ansi 10.1.80.182" oShell.SendKeys("{Enter}") WScript.Sleep 500 oShell.SendKeys"AT" oShell.Sendkeys("{ENTER}") WScript.Sleep 1000 oShell.SendKeys"AT"&("{+}")&"CMGF"&("{=}")&"1" WScript.Sleep 1000 oShell.SendKeys("{ENTER}") WScript.Sleep 1000 oShell.SendKeys"AT"&("{+}")&"CMGS"&("{=}")&"xxxxxxxxxx" WScript.Sleep 1000 oShell.SendKeys"{Enter}" WScript.Sleep 10000 oShell.SendKeys Stuff WScript.Sleep 5000 oShell.SendKeys"^(Z)" WScript.Sleep 15000 oShell.run"taskkill /F /IM telnet.exe" WScript.Sleep 10000 oShell.SendKeys"exit" oShell.SendKeys"{Enter}" Wscript.Quit I really hope someone can shed some light on this one for me, because I'm lost at the moment. Many thanks! Regards, Arjan.
May 25th, 2011 6:00am

Hi Arjan, Try to use the cscript.exe instead of cmd.exe here "Full path: %windir%\system32\cmd.exe"http://OpsMgr.ru/
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2011 6:13am

Hi Alexey, I tried that. Unfortunately, the result is the same: It works from the command line, but not from within SCOM. Command line: %windir%\system32\cscript.exe c:\send_sms.vbs $Data/Context/DataItem/AlertName$ Notification Channel: - Full path: %windir%\system32\cscript.exe - Parameters: c:\send_sms.vbs $Data/Context/DataItem/AlertName$ - Startup folder: C:\
May 25th, 2011 6:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics