Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup Client Security.evt On Server

Status
Not open for further replies.

cubzwin

Programmer
Feb 1, 2005
1
US
Ok,

Here's my code...

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://DC=MyDomain,DC=com' " _
& "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
strComputer = objRecordSet.Fields("Name").Value
Wscript.Echo "Computer Name: " & strComputer
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("SELECT * FROM Win32_NTEventLogFile WHERE LogFilename = 'Security'")
For Each objLogfile in colLogFiles
If objLogFile.FileSize > 1 Then
strBackupLog = objLogFile.BackupEventLog _
("\\MyServer\Audit\" & strComputer & " " & objLogFile.LogFileName & ".evt")
objLogFile.ClearEventLog()
End If
Next
objRecordSet.MoveNext
Loop

When run on the domain server I have a problem, only the server security log gets backed up in the shared Audit folder. Oddly enough, when run on the server it does clear the client security event log it just doen't make a backup copy on the server. When I run the script on the client everything works perfect. All computer security event logs get backed up into the shared Audit folder on the server and then cleared. Why does this not work when run on the domain server?

Any ideas????

Thanx,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top