You must be logged in and have permission to create or edit a blog.
|
|
Set-NotificationForAlert
Sep
19
Written by:
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
16 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
|
Re: Set-NotificationForAlert
I did see some help at rapidshare download which i usually use as my source for everything. 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 Alex on
Wednesday, June 16, 2010 12:41:02 PM
|
Re: Set-NotificationForAlert
Hi Alex, look at this page, number 3 describes how to change the email body to HTML. alipka.wordpress.com/2008/03/22/opsmgr-2007-notifications-issues-customizations/
cheers
By Stefan Koell on
Wednesday, June 16, 2010 1:10:36 PM
|
Re: Set-NotificationForAlert
I need to set notification to send emails to 2 receipents when any of the 9 application services fail. I've created a monitor for these 9 services. 1) Now do I run your script from power shell just once or it needs to be added in some scheduled task. 2) C:\Set-NotificationForAlert.ps1 "Application1 service stopped" "abc-email" and C:\Set-NotificationForAlert.ps1 "Application1 service stopped" "def-email" or C:\Set-NotificationForAlert.ps1 "Application1 service stopped" "abc-email,def-email" Same for remaining services again or anything else to do ?
By Hare krishna Agrawal on
Thursday, November 18, 2010 12:58:33 PM
|
Re: Set-NotificationForAlert
You just need to run the script once. The script creates a notification subscription. But let me mention that the above script is obsolete in SCOM 2007 R2! Since R2, they extended the criteria wizard to handle this special case. cheers, Stefan
By Stefan Koell on
Thursday, November 18, 2010 1:00:08 PM
|
Re: Set-NotificationForAlert
Hi stefan,
can you please provide us with a script fo scom 2k7 r2.
thanks
By manish on
Friday, December 24, 2010 8:33:49 PM
|
Re: Set-NotificationForAlert
Hi Manish,
in SCOM 2007 R2 this script is obsolete. The subscription dialog allows you to specify the monitor or rule raising the alert to trigger an email.
If you need help setting up the criteria, let me know.
cheers, Stefan
By Stefan Koell on
Sunday, December 26, 2010 12:48:31 PM
|
Re: Set-NotificationForAlert
Hi Stefan,
Thanks for the update. Actually my requirement is very simple but scom 2007r2 is not fulfilling it. I have to capture each alertid and send an email with alertid and its details ( like a link for resolution to that alert, ) using the script. Script will capture alertid, get info for that alertid like (monitorid or ruleid) then using that monitorid or ruleid, it will search the cprresponding link and append it to the emailbody
something like alertid : ------------------------ description: ------------------- solution: ---------------
i really appreciate any kind of help from you on this. :)
Thanks manish
By Manish on
Monday, December 27, 2010 9:01:26 AM
|
|
|
|
|
|