'Example script to use in the OpsMgr Command Notification Channel to 'send Email Notifications based on Alert Description to Solution groups. 'Some info for this script is taken from Script: Notification Logfile weblog article by Anders Bengtsson 'http://contoso.se/blog/?p=265 Option Explicit Dim colNamedArguments Dim AlertDescription Dim AlertSource Dim AlertName Dim AlertSev Dim AlertPrio Dim AlertState Dim objEmail Dim objShell Dim strContents Dim strEventCreate Dim strEventDescription Dim strFrom Dim strSub Dim strBody Dim strSMTP Dim strTo Set colNamedArguments = Wscript.Arguments.Named Set objShell = CreateObject("Wscript.Shell") ' ****************************************** ' GET PARAMETERS INTO SCRIPT ' ****************************************** AlertDescription = colNamedArguments("desc") 'Use: /desc:"$Data/Context/DataItem/AlertDescription$" in Notification Command Channel Command Line parameters AlertName = colNamedArguments("alert") 'Use: /alert:"$Data/Context/DataItem/AlertName$" in Notification Command Channel Command Line parameters AlertSource = colNamedArguments("source") 'Use: /source:"$Data/Context/DataItem/ManagedEntityDisplayName$" in Notification Command Channel Command Line parameters AlertSev = colNamedArguments("sev") 'Use: /sev:"$Data/Context/DataItem/Severity$" in Notification Command Channel Command Line parameters AlertPrio = colNamedArguments("prio") 'Use: /prio:"$Data/Context/DataItem/Priority$" in Notification Command Channel Command Line parameters AlertState = colNamedArguments("state") 'Use: /state:"$Data/Context/DataItem/ResolutionStateName$" in Notification Command Channel Command Line parameters 'Complete Notification Command Channel Command Line parameter: ' /c d:\scripts\notificationalertdescriptionv0.1.vbs /desc:"$Data/Context/DataItem/AlertDescription$" /alert:"$Data/Context/DataItem/AlertName$" /source:"$Data/Context/DataItem/ManagedEntityDisplayName$" /sev:"$Data/Context/DataItem/Severity$" /prio:"$Data/Context/DataItem/Priority$" /state:"$Data/Context/DataItem/ResolutionStateName$" 'Alert Description from OpsMgr Alert strContents = AlertDescription ' ****************************************** ' TRANSLATE SEVERITY AND PRIORITY ' ****************************************** if AlertSev = "1" Then AlertSev = "Critical" elseif AlertSev = "2" then AlertSev = "Warning" elseif AlertSev = "3" then AlertSev = "Information" End If if AlertPrio = "1" Then AlertPrio = "High" elseif AlertPrio = "2" then AlertPrio = "Medium" elseif AlertPrio = "3" then AlertPrio = "Low" End If ' ****************************************** ' SCRIPT LOGIC ' ****************************************** ' Configure on "serverx" the string which determines to which email address an email notification should be sent. 'Change the search string If InStr(strContents, "serverx") Then 'Configure email address Solution Group X strTo = "solutiongroupx@contoso.local" 'Send email Call SendEMail(strTo) End If 'Change the search string If InStr(strContents, "servery") Then 'Configure email address Solution Group Y strTo = "solutiongroupy@contoso.local" 'Send email Call SendEMail(strTo) End If ' ****************************************** ' MAIL CONFIGURATION ' ****************************************** strFrom = "opsmgrnotification@contoso.local" strSub = "Notification from Operations Manager 2007. Severity: " & AlertSev & ". Priority: " & AlertPrio & ". State: " & AlertState strBody = "Notification from Operations Manager" & VBCRLF & VBCRLF & "Alert Name: " & AlertName & VBCRLF & "Alert Source: " & AlertSource & VBCRLF & "Alert Description: " & AlertDescription strSMTP = "mail.contoso.local" ' ****************************************** ' SEND MESSAGE ' ****************************************** Public Function SendEmail(strTo) set objEmail = CreateObject("CDO.Message") objEmail.From = strFrom objEmail.To = strTo objEmail.Subject = strSub objEmail.Textbody = strBody objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP objEmail.Configuration.Fields.Update objEmail.Send End Function