'************************************************************************* ' Script Name - Auto resolve an Alert ' ' Purpose - To Resolve an alert generated by another MOM Rule ' ' Parameters - Rule - The GUID property of the Rule that generated the ' alert(s) which is intended to be resolved on a specific ' computer. ' ' (c) Copyright 2002, Microsoft Corporation, All Rights Reserved ' Proprietary and confidential to Microsoft Corporation ' ' This sample is provided "as is" for informational purposes only ' and Microsoft makes no warranties, either express or implied, of ' fitness for a particular purpose, of accuracy or completeness of ' responses, of results, or conditions of merchantability. No ' technical support is provided. '************************************************************************* Dim objAlert, objAlerts, objComputers, objComputer, strQuery Dim strRule, strComputerGUID, strComputer 'get the input parameters strRule = ScriptContext.Parameters.Get("Rule") 'check if the Rule context is an Event If (ScriptContext.IsEvent()) Then Set objEvent = ScriptContext.Event strComputer=objEvent.SourceComputer End If 'get the computer guid property strQueryComputer= "Select * from MSFT_Computer where Name=""" + strComputer + """" set objComputers = GetObject("winmgmts:!root\MOM").ExecQuery(strQueryComputer) 'there should only be one that matches for each objcomputer in objComputers If Err.Number = 0 Then strcomputerguid = objcomputer.guid End If next 'now query for all the alerts with a specific RuleGUID strQuery = "select * from MSFT_Alert where RuleGUID=""" + strRule + """" Set objAlerts = GetObject("winmgmts:!root\MOM").ExecQuery(strQuery) 'now enumerate through the alerts to find unresolved 'alerts (255) associated to the right computer For Each objAlert In objAlerts If Err.Number = 0 Then If Not objAlert.ResolutionState=255 Then 'now check if you have the right computer set objComputers = objAlert.Associators_(,"MSFT_Computer",,,FALSE,FALSE,,,,null) For Each objComputer in objComputers If objComputer.GUID=strComputerGUID Then 'auto resolve the alert objAlert.ResolutionState = 255 objAlert.Put_ End If Next End If End If Next