ENHANCED SCOM Alerts Notification Emails!

3 minute read

17/08/2012: The version 2 of this script has just been released: https://blog.tyang.org/2012/08/16/scom-enhanced-email-notification-script-version-2/

29/01/2012: The command notification channel setup section of this blog has been updated. More details of the change can be found HERE: https://blog.tyang.org/2012/01/29/command-line-parameters-for-scom-command-notification-channel/

Please Note: This post and associated script has been updated on 30/09/2010.**

Even though SCOM is a great product, I personally believe that alert notification emails is something that really needs improvements. It is very hard (and almost impossible – according to my standard) to configure a meaningful notification email using the variables SCOM provides.

Most of times, the SCOM administrator would include a URL that takes you straight to the alert using SCOM web console. Web Console is greatly improved in SCOM 2007 R2, and it pretty much contains everything about the alert (such as alert name, description, source, time raised, monitor/rule name, description, knowledge article, etc).

image

But why can’t we have all this information in the notification email so we don’t have to come to the web console?

This cannot be done natively using SMTP notification channels. I accomplished it almost 2 years ago for my previous employer, using PowerShell and SCOM Command Notification Channel. I wrote a PowerShell script to utilise System.Net.Mail classes to send out HTML formatted email that contains EVERYTHING that you can get from SCOM Operations Console or Web Console.

The following information is included in the notification email:

    • Alert name, description, severity, resolution state, source, path, Time created
    • Monitor / Rule name
    • Knowledge Article for the particular monitor / rule
    • Web console URL link to the alert
    • PowerShell command to retrieve the alert from SCOM command console

I completed forgot about this script until recently one of my customer’s support team asked me if there are any better ways to configure Alert Notification emails in SCOM. Now I’ve decided to post it in my blog so you all can benefit from it.

Below is the email notification for the alert from the above web console screenshot:

image

OK. if you want to try this out in your SCOM environment, please keep reading. Let’s go through the steps setting this up in SCOM:

  1. Download SCOMEnhancedEmailNotification.ps1

  2. Modify this section of the script (line 26-48, Highlighted in Yellow):

image

  • $NotifiedResState – At the end of this script, after the email is sent, it changes the resolution state of the alert to “Notified”. I have manually created such resolution state using SCOM Operations Console with number 85. You can use other number if you wish, just make sure this variable represent the right number of the resolution state you want the script to set the alert to at the end.
  • Function getResStateName - Modify function getResStateName to have ALL the resolution states for your SCOM environment.
  • $strSMTP – The FQDN of your SMTP server
  • $iPort – Port used for SMTP. default is 25. if your SMTP server is not use port 25, please change this variable accordingly.
  • $Sender – make sure you have the sender (return address) and the display name set inside the bracket( )
  • $ErrRecipient – If the script is running into errors, it will try to email the error message to this recipient. I’d suggest you to set this to your company’s SCOM administrator so they know there is a problem.
  1. Once the script is modified, save it to a local folder on your RMS server. In this blog, we will use *D:\Scripts* as an example.

  2. Setting up SCOM Command notification channel:

NOTE: Because we are not using SMTP channels, we cannot specify the email addresses in Subscriber’s properties. Instead, we are passing in the email addresses as parameters. So for subscriptions with different subscribers, you will need to create multiple command channels with different email addresses.

image

Settings:

  • Full path of the command file: C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe
  • Command line parameters: -Command “& ‘“D:\Scripts\SCOMEnhancedEmailNotification.ps1”’” -alertID ‘$Data/Context/DataItem/AlertId$’ -Recipients @(‘Tao Yang;Tao.Yang@xxxx.com’,John Smith;John.Smith@xxxx.com‘)
  • Note:

  • Recipients are passed into the script as an array variable. make sure you use this format inside the (): Recipient 1 Name;Email’,’Recipient 2 Name;Email
  • Alert ID is quoted using single quotation mark ONLY.

  • Startup folder for the command line: D:\Scripts
  • This is the location of the script
  1. Setting up subscribers

Subscriber1

Subscriber2

Subscriber3

Subscriber address:

image

  1. Setting up subscriptions

Subscription3

Subscription4

One last thing to remember: The powerShell execution policy on your RMS needs to set to RemoteSigned or Unrestricted.

This script can be downloaded HERE. Feel free to email me if you are having issues setting this up!

Leave a comment