I am trying to create an array(list of machine names) and use this array to perform a recursive scan on all machines c: drives in the network.
I want to scan for exe, iso ...
I want to export each file it finds to an excel spread sheet.
So far I have the array working and the spread sheet working. I can do a export to csv, but everything is in one cell and the array overwrites the entry before it.
I would like separate cells for machine name, filename, path, and file size.
Please help.
Thanks,
TREP
$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(1,1) = "Computer"
$Sheet.Cells.Item(1,2) = "File_Name"
$Sheet.Cells.Item(1,3) = "Directory"
$Sheet.Cells.Item(1,4) = "File_Size"
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 8
$WorkBook.Font.ColorIndex = 11
$WorkBook.Font.Bold = $True
$intRow = 2
Foreach($strComputer in get-content C:\PS_Scripts\servers.txt)
{
$Sheet.Cells.Item($intRow,1) = $strComputer
$colItems = $strComputer | %{gci \\$_\c$\ -include *.exe -recurse}
foreach ($objItem in $colItems) {
$Sheet.Cells.Item($intRow,1) = $strComputer
$Sheet.Cells.Item($intRow,2) = $_.name
$Sheet.Cells.Item($intRow,3) = $_.path
$Sheet.Cells.Item($intRow,4) = $_.length
$intRow = $intRow + 1
}
}
$WorkBook.EntireColumn.AutoFit()
Clear