I think I am on the right track with this script but I know Im missing some very important information.
The purpose of this script is to tell me the following:
1. The computers host name
2. The file it scanned
3. The file's location on the hard drive
4. The version of the file it found
I am looking to find all versions of the file GDIPLUS.DLL that is on a computers hard drive. This file is used by many different programs and is found in various locations on the hard drive as it is dependant on what softwares loaded on that computer. I have to check several hundred computers and would like to use Power Shell for this.
The way I have this written is I click on a BAT file to launch it. That opens a text file I will be using to put in the hosts I want to scan. Then it starts a scan on a remote computer thats listed in the forst text file. An Excel document opens and is supposed to fill in the information but I can't figure out how to get it to do that. That's the missing information.
Here is the script I have, can anyone help me finish this please?
$WorksheetName = "Software Versions"
$ServerList = "C:\script\servers.txt"
$SaveFile = "C:\script\Software_Versions.xlsx"
$SaveFileHTM = "C:\Inetpub\wwwroot\Software_Versions.htm"
$LastColumn = "O"
$xlAutomatic = -4105
$xlBottom = -4107
$xlCenter = -4108
$xlContext = -5002
$xlContinuous = 1
$xlDiagonalDown = 5
$xlDiagonalUp = 6
$xlEdgeBottom = 9
$xlEdgeLeft = 7
$xlEdgeRight = 10
$xlEdgeTop = 8
$xlInsideHorizontal = 12
$xlInsideVertical = 11
$xlNone = -4142
$xlThin = 2
$erroractionpreference = "SilentlyContinue"
######################################################
# Create Excel document and format Header
######################################################
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$b.workSheets.item(3).delete()
$b.workSheets.item(2).delete()
$b.WorkSheets.item(1).Name = $WorksheetName
$c = $b.Worksheets.Item(1)
$c.Application.ActiveWindow.SplitColumn = 1
$c.Application.ActiveWindow.SplitRow = 1
$c.Application.ActiveWindow.FreezePanes=$true
$c.Cells.Item(1,1) = "Server Name"
$c.Cells.Item(1,2) = "GDIPLUS.DLL"
$c.Cells.Item(1,3) = "File Location"
$c.Cells.Item(1,4) = "Version Number"
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$intRow = 2
######################################################
# ROWS - data
######################################################
$colComputers = get-content $serverList
foreach ($strComputer in $colComputers)
{
$GDIPLUS = " "
$GDI = [system.diagnostics.fileversioninfo]::GetVersionInfo("\\$strComputer\admin$\GDIPLUS.DLL").ProductVersion
$c.Cells.Item($intRow,1) = $strComputer.Toupper()
$c.Cells.Item($intRow,2) = $GDIVersion
$intRow = $intRow + 1
}
######################################################
# Format data
######################################################
$FormatRange = ("A1:" + $LastColumn) + ($intRow - 1)
$ws = $b.worksheets | where {$_.name -eq $WorksheetName}
$selection = $ws.range($FormatRange)
$selection.select()
$selection.HorizontalAlignment = $xlCenter
$selection.VerticalAlignment = $xlBottom
$selection.WrapText = $false
$selection.Orientation = 0
$selection.AddIndent = $false
$selection.IndentLevel = 0
$selection.ShrinkToFit = $false
$selection.ReadingOrder = $xlContext
$selection.MergeCells = $false
$selection.Borders.Item($xlInsideHorizontal).Weight = $xlThin
$selection.Borders.Item($xlInsideHorizontal).LineStyle = $xlContinuous
$selection.Borders.Item($xlInsideHorizontal).ColorIndex = $xlAutomatic
$selection.Borders.Item($xlInsideVertical).Weight = $xlThin
$selection.Borders.Item($xlInsideVertical).LineStyle = $xlContinuous
$selection.Borders.Item($xlInsideVertical).ColorIndex = $xlAutomatic
$selection.Borders.Item($xlEdgeLeft).Weight = $xlThin
$selection.Borders.Item($xlEdgeLeft).LineStyle = $xlContinuous
$selection.Borders.Item($xlEdgeLeft).ColorIndex = $xlAutomatic
$selection.Borders.Item($xlEdgeRight).Weight = $xlThin
$selection.Borders.Item($xlEdgeRight).LineStyle = $xlContinuous
$selection.Borders.Item($xlEdgeRight).ColorIndex = $xlAutomatic
$selection.Borders.Item($xlEdgeTop).Weight = $xlThin
$selection.Borders.Item($xlEdgeTop).LineStyle = $xlContinuous
$selection.Borders.Item($xlEdgeTop).ColorIndex = $xlAutomatic
$selection.Borders.Item($xlEdgeBottom).Weight = $xlThin
$selection.Borders.Item($xlEdgeBottom).LineStyle = $xlContinuous
$selection.Borders.Item($xlEdgeBottom).ColorIndex = $xlAutomatic
$Selection.Font.Size = 10
$Selection.AutoFilter()
$d.EntireColumn.AutoFit()
######################################################
# Save as XLSX
######################################################
$xlExcel8 = 51
$b.SaveAs($SaveFile,$xlExcel8)
$xlExcel8 = 44
$b.SaveAs($SaveFileHTM,$xlExcel8)
$a.Quit()