This VBS script will take a list of machines from a text file called MachineList.Txt and will write the machine name, specified log file name and the specified log files size in MB to an excel spreadsheet.
Note: The script can be modified to get the file size for any file as long as the file name and file path that is hard coded is available on all machines in the list as I have no error checking added to first verify that the file does in fact exist.
VBS Script:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "Log File Name"
objExcel.Cells(1, 3).Value = "Log File Size"
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from CIM_DataFile Where name = 'C:\\WINDOWS\\system32\\CCM\\Logs\\InventoryAgent.Log'")
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = UCase(strComputer)
objExcel.Cells(intRow, 2).Value = UCase(objItem.FileName)
objExcel.Cells(intRow, 3).Value = FormatNumber(objItem.FileSize/1024/1024,1) & " MB"
intRow = intRow + 1
Next
Loop
objExcel.Range("A1:C1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
No Comments