I have a script that works. I am sure there is a better way to do it.
I am outputing the file properties for all files in a specified directory to
an excel file. I can not figure out a way to include the owner property. I
found something that does pull owner information - it also pulls alot of
information i don't want and i have no idea how to integrate it into my
existing script.
Below i pasted both the script that pulls owner property and my existing
script. Any help getting getting the "existing script" to pull the ower
property is appreciated.
***********************
' pulls info on owners and extras
Dim arrHeaders(34)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Scripts")
For i = 0 to 33
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
For i = 0 to 33
Wscript.Echo i & vbtab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(strFileName, i)
Next
Next
***************************
'Existing script
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='H:\scripts'} Where " _
& "ResultClass = CIM_DataFile")
i = 2
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
'open spreadsheet
Set objWorkbook = objExcel.Workbooks.Open("h:\spreadsheet.xls")
Set objWorksheet = objWorkbook.Worksheets(1)
objExcel.Cells(1, 1).Value = "File Name"
objExcel.Cells(1, 2).Value = "File Path"
objExcel.Cells(1, 3).Value = "File Size in Bytes"
objExcel.Cells(1, 4).Value = "Date Created"
objExcel.Cells(1, 5).Value = "Last Accessed"
objExcel.Cells(1, 6).Value = "Last Modified"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 2).Font.Bold = TRUE
objExcel.Cells(1, 3).Font.Bold = TRUE
objExcel.Cells(1, 4).Font.Bold = TRUE
objExcel.Cells(1, 5).Font.Bold = TRUE
objExcel.Cells(1, 6).Font.Bold = TRUE
For Each objItem In colFileList
objworksheet.cells(i, 1).Value = objItem.FileName
objWorksheet.cells(i, 2).value = objItem.Description
objWorksheet.cells(i, 3).value = objItem.FileSize
objWorksheet.cells(i, 4).value = WMIDateStringToDate(objItem.CreationDate)
objWorksheet.cells(i, 5).value = WMIDateStringToDate(objItem.LastAccessed)
objWorksheet.cells(i, 6).value = WMIDateStringToDate(objItem.LastModified)
i = i + 1
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate,5,2) & "/" & _
Mid(dtmDate,7,2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate,9,2) & ":" & Mid(dtmDate,11,2) & ":" &
Mid(dtmDate,13,2))
End Function
Dim arrHeaders(34)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("H:\DoubleTake\scripts")
For j = 0 to 33
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, j)
Next
For Each strFileName in objFolder.Items
For j = 0 to 33
Wscript.Echo i & vbtab & arrHeaders(j) _
& ": " & objFolder.GetDetailsOf(strFileName, j)
Next
Next