Operations Manager Command Shell Main Menu
Welcome to TechNet Blogs Sign in | Join | Help
MOM 2005 - Resolve all alerts generated by specific rule

Copy this script into a .vbs file.  Edit line 15 (objAlert.Name = "ALERT NAME HERE") to match the name of the alerts you want to resolve.  Run this from a MOM 2005 Management Server.

Set objWMI = GetObject("winmgmts://./root/MOM")
strQuery = "select * from MSFT_Alert where ResolutionState <> 255"
Set colAlerts = objWMI.ExecQuery(strQuery)
For Each objAlert In colAlerts
   If Len(Trim(objAlert.AlertHistoryComment)) = 0 Then objAlert.AlertHistoryComment = Null
   If Len(Trim(objAlert.CustomField1)) = 0 Then objAlert.CustomField1 = Null
   If Len(Trim(objAlert.CustomField2)) = 0 Then objAlert.CustomField2 = Null
   If Len(Trim(objAlert.CustomField3)) = 0 Then objAlert.CustomField3 = Null
   If Len(Trim(objAlert.CustomField4)) = 0 Then objAlert.CustomField4 = Null
   If Len(Trim(objAlert.CustomField5)) = 0 Then objAlert.CustomField5 = Null
   If Len(Trim(objAlert.Description)) = 0 Then objAlert.Description = Null
   If Len(Trim(objAlert.OwnerName)) = 0 Then objAlert.OwnerName = Null
   If Len(Trim(objAlert.ResolvedBy)) = 0 Then objAlert.ResolvedBy = Null
   If Len(Trim(objAlert.TimeResolved)) = 0 Then objAlert.TimeResolved = Null
   If objAlert.Name = "ALERT NAME HERE" then
      objAlert.ResolutionState = 255
      objAlert.Put_
   End If
Next

Additional notes:

If we execute an Update query to the OnePoint DB directly, we are essentially circumventing MOM from performing it's normal Alert update process and some interesting fields (like TimeResolved, ResolvedBy, etc) will not be updated properly.  This is why it's recommended to use this method if the console will not suffice.

Also, a note about updating particular blank fields in the script to NULL.  If these blank fields are not updated to NULL, the script will fail.  This is not a SQL or MOM issue.  It's a problem with SWBemObjectEx.  Blank fields cannot be handled.  Specifically, you'll receive the following error:

clip_image002

Posted: Wednesday, March 05, 2008 3:09 PM by jtalmquist

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker