Updated: Enhanced SCOM Alerts Notification Emails script
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)
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.
I have also updated the original post, so this script can still be downloaded from the download link on the original post.