|
|
Sep
19
Written by:
Stefan Koell
Wednesday, September 19, 2007 2:43:37 AM
In MOM 2005 it was easy to notify someone on specific alerts. SCOM 2007 - with it's subscription based system - cannot handle these kind of notifications. But the limitation is the user interface. Jakub from the SCOM 2007 product team released some very useful code which helped to implement a notification based on the alert name. One problem of Jakubs code is, that it's a C# program which is not very handy and that he creates most of the stuff in code which can be created with the UI. I translated the script to power shell, which should be much friendlier to use, deploy and let's you quickly tweak some settings. The code below works for me (at least working with email notifications), but I have to admit, I didn't test it that much. The script usage is pretty simple, but you have to do some stuff first: - Setup email notification
- Create at least one recipient
- The alert has to be raised at least once
- Change the $RMS variable in the script to your root management server
Then, just execute it in Power Shell: ".C:\Set-NotificationForAlert.ps1 "This is a test alert" "This is a test notification recipient" Parameter 1: The name of the alert Parameter 2: The name of the recipient So, hopefully I can ease some pain with this... Set-NotificationForAlert.ps1
Tags:
9 comment(s) so far...
Re: Set-NotificationForAlert
Hi,
I am just new on scom 2007 i just what to send the alert in HTML format how this can be done please provide any help for this. can this be done using powershell script
By narendra on
Friday, February 06, 2009 11:02:13 PM
|
Re: Set-NotificationForAlert
I was able to set this up and it does create subsciptions for any alerts on which I run this script. The problem I am having is that if I crete multiple alerts that are similar and create the subscriptions, they overlap. So, when 1 alert is triggered the notification is sent from all of the subscriptions.
I was trying to isolate a particual alert from a particular system. Then if i create a 2nd alert of the same type on a 2nd system the 2 subscriptions should stay separate.
Please let me know.
By Steve Kramer on
Friday, February 06, 2009 11:02:17 PM
|
Re: Set-NotificationForAlert
Stefan,
I noticed that the cmdlet cannot be run in below command line. Do you have any ideas? Thanks in advance!
**************************************************************************
E:\>powershell C:\Set-NotificationForAlert.ps1 "Testing Rule" "Simon"
Executing Set-NotificationForAlert.ps1 ...
File OpsMgrV3.ps1 loaded. Initializing shell for operations manager... Add Microsoft.EnterpriseManagement.OperationsManager.Client snap in. Connect to Management Server: SCOM2007
PathName : ManagementGroup : SCOM Management Group ManagementServerName : SCOM2007 Drives :
Create Monitoring drive from Provider.
Name Provider Root CurrentLocation ---- -------- ---- --------------- Monitoring Operations... Operations manager shell initialized.
No alert was found with the specified name ScriptHalted At C:\Set-NotificationForAlert.ps1:53 char:8 + throw <<<< write-host "No alert was found with the specified name"
**************************************************************************
By Simon Kwok on
Tuesday, February 17, 2009 9:27:35 PM
|
Re: Set-NotificationForAlert
I'm not sure, has your rule already raised an alert once? Also keep in mind, that the script only works for alerts which are raised from rules. Alerts raised from monitors do not work with this script.
By Stefan Koell on
Tuesday, February 17, 2009 9:27:24 PM
|
Re: Set-NotificationForAlert
Stefan,
Thanks for your reply. Actually, I have further two questions as below:
1. Can your PS script be modified to have custom email message content as stored in the subscription? (Your script can create the subscription with default email message content. However, after I altered the email contents in the subscription with custom contents, the subscription seems to be "corrupted". I got various email notifications that is not come from the specified alert rule, which is originally worked perfectly.) 2. I got two alert rules (with the same alert rule name) under different "Computer Type", how can I distinguish the correct alert rule name using the PS script?
Any ideas are much appreciated. Thanks in advance!
Simon
By Simon Kwok on
Monday, February 23, 2009 9:11:28 AM
|
Re: Set-NotificationForAlert
Hi Simon,
1. The script creates a subscription criteria which is not compatible with the UI. There is nothing we can do about it. I heard that the future versions of OpsMgr will handle this gracefully. They display at least the XML from the criteria when the UI can not handle it. 2. The created criteria is based on the "Alert Name". When both rules have the same name but different alert names in the alerting tab you have no problem. Otherwise you need to extend the criteria to match the right rule. I think one safe possibility is to use the Rule GUID but I'm not sure if there is already enough documentation about that stuff, haven't looked at it for a while now...
cheers
By Simon Kwok on
Monday, February 23, 2009 9:17:33 AM
|
Re: Set-NotificationForAlert
I need help on this above of 3.point that is HTML MAIL Body. i have used and insterted the HTML code in that but it is not working; When see on XML file i see in a Grey Color text btween the CDATA it is not processing it. how this can be done please give and details step how it can done. tried to find some info myself by rapid4me.com SE still hope to get help here.
By Edward Green on
Wednesday, February 03, 2010 9:00:10 AM
|
Re: Set-NotificationForAlert
Hi Edward, I'm afraid I do not understand. You can contact me directly using the contact page on this website with more details. cheers
By Stefan Koell on
Wednesday, February 03, 2010 9:03:03 AM
|
Re: Set-NotificationForAlert
Thanks for this informative post. it's well written and useful. This is a nice blog and will be looking forward to read more from you. I found your blog on Google and read a few of your other posts. I just added you to my Google Reader. Keep up the good work!
By Unknown on
Monday, March 08, 2010 9:10:15 AM
|
|
|
|
Search Blog
|
|
You must be logged in and have permission to create or edit a blog.
|
|
|