SWbemObjectEx: Generic failure when trying to modify MOM alert property through WMI
- From: "doomster@xxxxxxxxxxxx" <doomster@xxxxxxxxxxxx>
- Date: 18 Oct 2006 18:07:21 -0700
Hi,
I am trying to update the CustomField4 field under MSFT_Alert in WMI on
a Windows 2003 Sp1 Server. I have the following code that i run from my
workstation (XPSP2 - i also have admin credentials) below..
----------------------------------------------------------------------------------------------------------------------
paramesc = "20"
strComputer = "MOMMAN1"
set objWMI = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\mom")
strQuery = "Select * from MSFT_Alert where Severity >= 50 and
ResolutionState = 0 and CustomField4 > 0"
Set colAlerts = objWMI.ExecQuery(strQuery)
For Each objAlert in colAlerts
intEscalationInterval = CInt(objAlert.CustomField4)
intMinutesOpen =
CInt(DateDiff("n",ConvertDateFromUT(objAlert.TimeRaised),ConvertDateToGMT(Now)))
If intMinutesOpen > intEscalationInterval Then
If objAlert.CustomField4 = "10" Then
objAlert.CustomField4 = "20"
objAlert.Put_
End If
End If
Next
'**************************************************************************************************
' Sub: ConvertDateFromUTC
' Purpose: Converts a variant date UTC format to a variant.
' Returns: Variant date
'**************************************************************************************************
Function ConvertDateFromUTC(strUTCDate)
strDateTime = Left(strUTCDate,InStr(strUTCDate,"."))
intHourOffset = 0 - Right(strUTCDate,4)/60
strDateString = Mid(strUTCDate,5,2) & "/" & Mid(strUTCDate,7,2) & "/"
& Mid(strUTCDate,1,4)
strTimeString = Mid(strUTCDate,9,2) & ":" & Mid(strUTCDate,11,2) & ":"
& Mid(strUTCDate,13,2)
ConvertDateFromUTC = DateAdd("h",intHourOffset, strDateString & " " &
strTimeString)
End Function
'**************************************************************************************************
' Sub: ConvertDateToGMT
' Purpose: Converts a date to GMT.
' Returns: Variant date.
'**************************************************************************************************
Function ConvertDateToGMT(datLocalDate)
strQuery = "Select * From Win32_TimeZone"
Set colTimeZones =
GetObject("winmgmts:\\.\root\cimv2").ExecQuery(strQuery)
For Each objTimeZone in colTimeZones
intTimeZoneBias = objTimeZone.Bias
intDaylightBias = objTimeZone.DaylightBias
Next
ConvertDateToGMT =
DateAdd("n",intDaylightBias,DateAdd("n",-intTimeZoneBias,datLocalDate))
End Function
----------------------------------------------------------------------------------------------------------------------------------
I get a "SWbemObjectEx: Generic failure" on the objAlert.Put_ line.
Any ideas what could be causing this and how i can resolve it?
I have also tried using Wbemtest to modify the customfield4 on the
particular Alert instance and get a similar error when trying to save
the change.
regards
Asit
.
- Prev by Date: Re: Any creative ideas?
- Next by Date: Changes to WMI on Vista that would prevent custom WMI Provider DLL from loading?
- Previous by thread: Re: Any creative ideas?
- Next by thread: Changes to WMI on Vista that would prevent custom WMI Provider DLL from loading?
- Index(es):
Loading