When I run the script below (which should set the event log sizes), I
get the following error:
Line:14
Char: 1
Error: An amended object cannot be put unless
WBEM_FLAG_USE_AMENDED_QUALIFIERS is specified
Code: 80041066
Source: SWbemObject
For the short term, how do I do this? We had an admin who left all
our event logs at the default size and I have about 50 servers to
change.
For the long term, what is an "amended object" and why do I need to
worry about it? :)
As always, any help is appreciated.
BTW... this works fine on my XP box, but does NOT work on the W2k
server.
---------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For each objLogfile in colLogFiles
strLogFileName = objLogfile.Name
Set wmiSWbemObject = GetObject _
("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:" _
& "Win32_NTEventlogFile.Name='" & strLogFileName & "'")
wmiSWbemObject.MaxFileSize = 51183616
wmiSWbemObject.OverwriteOutdated = 14
wmiSWbemObject.Put_
Next
--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
>You'll get a faster answer if you repost the question to
>...win32.programmer.wmi.
Thanks, shall do.
--JwK
I actually managed to solve this one myself... Aparently, there's a
flag you have to set to tell it that you know you're updating an
amended property. Most of the flags for the Put method are powers of
two... but not this one (it's 131072).
I haven't figured out why my event log size is an amended property,
since that should only apply to localization (installing language
support other than US English), which we do not do. But, the code
below worked. You can find the flag right after the Put statement if
you're interested.
BTW Michael, your suggestion to post to the win32 group prompted me to
broaden my searching in MSDN where I finally found an article that
hinted at this solution. Thanks again.
--JwK
'----------------------------
'begin script
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For each objLogfile in colLogFiles
strLogFileName = objLogfile.Name
Set wmiSWbemObject = GetObject _
("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer &
"\root\cimv2:" _
& "Win32_NTEventlogFile.Name='" & strLogFileName & "'")
Wscript.echo "LogFileName: " & strLogFileName
Wscript.echo "MaxFileSize: " & wmiSWbemObject.MaxFileSize
Wscript.echo "OverwriteOutdated: " &
wmiSWbemObject.OverwriteOutdated
wmiSWbemObject.MaxFileSize = 51183616
wmiSWbemObject.OverwriteOutdated = -1
wmiSWbemObject.OverWritePolicy = "Never"
wmiSWbemObject.Put_(131072)
Next