Updated: Enhanced SCOM Alerts Notification Emails script

Written by Tao Yang

I have previously posted the Enhanced SCOM Alerts Notification email scripts back in July 2010.

I’d like to thank everyone who have tested it and provided feedbacks. You made me aware there are few issues and bugs with the script. Since I have just resigned and my new job won’t start in few weeks time, I have spent the last couple of days updating the script.

This is what I’ve done:

1. Removed GetNetbiosName function

  • Few people advised there are often this function running into errors.  I realised I originally wrote this function because one of my previous employers required the SCOM agent NetBios name in the email. but since SCOM is designed to monitor applications and objects rather than individual servers, I don’t see any reasons to include Computer NetBIOS name in the email. For sure it will often fail if the alert source is from a AD Site or distributed application, etc.
  • Instead, I’ve added Alert Source, Path and Principal name in the email.
  • P.S. I’ve also rewritten the function, trying to fix the bug. I’ve still left the
  • function in the script (but commented out). Feel free to use it somewhere else.

2. Reformatted HTML email body

  • I have changed the format of few items from <h3> (header 3) to just <b> (bold) to make the email more readable.
  • I also made the alert severity more visual: Critical is displayed in Red, Warning displayed in Yellow and information displayed in Blue (if you subscribe informational alerts)
  • image

3. Added error handling for $rule.GetKnowledgeArticle() as sometimes there is no knowledge article.

  • I often get error emails because GetKnowledgeArticle() method returns error. This is because not all rules and monitors will have knowledge articles associated to them.  I have added few lines of code to handle errors occurred when calling this method. basically if calling this method failed, it will remove the entry from $error.

4. Fixed the problem with unconverted Unicode characters (i.e. %002d)  displayed in emails.

  • Before:
  • image
  • After:
  • image

I have also updated the original post, so this script can still be downloaded from the download link on the original post.

5 comments on “Updated: Enhanced SCOM Alerts Notification Emails script

  1. I was reading your post and on ENHANCED SCOM Alerts Notification Emails!
    and on the last part of it you said “One last thing to remember: The powerShell execution policy on your RMS needs to set to RemoteSigned or Unrestricted.” How can I do this? I am new to SCOM 2007 and am finding a way to send alert via second channel notification.
    Thank you.

  2. BTW, am using SCOM 2007 SP1

  3. Hi there,
    sorry to bother you again.

    iused your script in my env and BIG thanks to you for the same.

    I was testing it for a couple of weeks and found that the script is not getting trigerred for all the alerts.

    1. i do have a subsciption using smtp channel by SCOM
    2. and similar subscription and same criteria using the command channel (in turn calling ur script).

    so during my test run, alert captured and sent as email by 1) were count to 500

    alert captured and sent by 2) were just 50, (90% were dropped).

    what shd we do to run the script for all alerts that are newly created without missing most of them.

    • Hi Manish, I think this might be performance related. is your RMS and SQL servers experiencing performance issues? also, have you tuned all your MPs? what’s the time frame for SCOM to generate those 500 alerts?

Leave a Reply