Few years ago, I posted the SCOM Enhanced Email Notification Script in this blog and became well adopted by the community. Over the last week or so, I have spent most of my time at night re-writing this script and I have completed the new version (2.0) now.
There are few reasons why I have decided to rewrite this script:
- Make it to work in SCOM 2012
- To be able to include Company Knowledge articles in the email (someone asked me about this a long time ago)
- Ability to use an external / public SMTP server (i.e. gmail) to send emails so I can decommission the Exchange server in my test lab. – since all I use this Exchange server for is to send out alert notifications and it can’t email out to the real world!
- Improve the email HTML body layout.
So what’s changed?
- Now the script uses SCOM SDK instead of SCOM PowerShell snap-in / module. And because of this, it works on both SCOM 2007 R2 and SCOM 2012. – so far, from my experience playing with the them, the SDK’s in SCOM 2007 and 2012 look pretty similar!
- Also because of the use of SCOM SDK, I’m able to retrieve Company Knowledge articles.
- In the original script, it would only retrieve knowledge articles when the language of the article is ENU (“en-US”). Therefore, any knowledge articles stored in other language packs (such as ENA) in the management pack would not be retrieved. The script now retrieve ALL knowledge articles AND ALL company knowledge articles and display ALL of them in the email (as shown in the sample below).
- I have moved all the customisations out of the script itself to a config.xml to store customised settings. No need to modify the PS1 script anymore. Simply make necessary changes in the config.xml and place it to the same folder as the script.
- When setting up a native SCOM SMTP notification channel, there are only 2 authentication methods you can choose from: Anonymous and Windows Integrated. This script can be configured to use a separate user name and password to authenticate to SMTP so external SMTP servers such as gmail can be used. This eliminates the needs of having to use Exchange server for mail relay.
- In the original script, the alert resolution state is updated once the script has processed the alert. This feature can now be turned off. – Because we don’t always want to update the resolution state.
- Additionally, I have made the email body look a bit tidier, the layout now looks more similar to the alert view in the SCOM consoles:
How to setup command subscription?
The command subscription setup is very similar to the previous version. However, for the new script, the web console link also needs to be passed into the script. I remove the section to generate web console link for the alert because the web console link can be passed into the script as a parameter natively by SCOM, why generate it again in the script when it’s already available natively?
Assuming the script is located on D:\Script folder of your RMS / MS. here’s how you set it up:
From zip file that you can download from the link at the end of this post, you’ll find these files:
- The version 2 of the SCOMEnhancedEmailNotification.ps1 script.
- config.xml that you will need to modify to suit your needs
- XML explaination.xlsx – explains each tag of the config.xml in details.
- Command Channel Setup.txt – what to enter when setting up command channel. (assuming the script is located at D:\Script). you can simply change the location of the script and email addresses, then copy & paste each field.
- XML Sample – contains 3 config.xml samples. one for each SMTP authentication method (Anonymous, Integrated and Credential).
The notifications subscriber and subscriptions are setup exactly the same way as the original version of the script. you can simply refer to the original blog post.