Hi, I am trying to find files using an array of server names
I want to display only files with create date of today
I want to only retrieve files with extensions dat or log
I am just a novice, so please provide generous how's. This is what I have put together so far.
arrServers = Array("10.32.44.192","10.32.44.193","10.32.44.194") ' server array
strDate = Date - 0 'file date selection
Set objDateToUtcDate = CreateObject("WbemScripting.SWbemDateTime") 'set date object
objDateToUtcDate.SetVarDate(strDate) 'set date var
For Each Server in arrServers ' for loop, 1 iteration per server
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Server & "\root\cimv2") 'Set COM impersonation allowing access
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where (Extension = 'log' or Extension = 'dat') and CreationDate < '" & objDateToUtcDate & "'") ' searching by the masks/date
For Each objFile in colFiles
Wscript.Echo objFile.Name 'show me the money
Next
Set colFiles = Nothing 'cleanup
Set objWMIService = Nothing 'cleanup
Next
Set objDateToUtcDate = Nothing 'cleanup
I want to display only files with create date of today
I want to only retrieve files with extensions dat or log
I am just a novice, so please provide generous how's. This is what I have put together so far.
arrServers = Array("10.32.44.192","10.32.44.193","10.32.44.194") ' server array
strDate = Date - 0 'file date selection
Set objDateToUtcDate = CreateObject("WbemScripting.SWbemDateTime") 'set date object
objDateToUtcDate.SetVarDate(strDate) 'set date var
For Each Server in arrServers ' for loop, 1 iteration per server
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Server & "\root\cimv2") 'Set COM impersonation allowing access
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where (Extension = 'log' or Extension = 'dat') and CreationDate < '" & objDateToUtcDate & "'") ' searching by the masks/date
For Each objFile in colFiles
Wscript.Echo objFile.Name 'show me the money
Next
Set colFiles = Nothing 'cleanup
Set objWMIService = Nothing 'cleanup
Next
Set objDateToUtcDate = Nothing 'cleanup