This is an excerpt from a larger very very old script that collects printer data into an Excel spreadsheet, I’m trying to get it to fill these specific fields.
The script is looking at the Windows print server to get all the printers installed within the print server.
I hope I get this formatted correctly.
$Drivers = Get-PrinterDriver -ComputerName $PrintServer
(The original line was
#$Drivers = Get-WmiObject Win32_PrinterDriver -Filter "__path like '%$($Printer.DriverName)%'" -ComputerName $Printserver
but this line basically does not work
ForEach ($Driver in $Drivers)
# 6/18 this loop is not getting the driver path or version, throws errors
{
$Drive = $Driver.DriverPath.Substring(0,1)
$Sheet.Cells.Item($intRow,7) = (Get-ItemProperty ($Driver.DriverPath.Replace("$Drive`:","\\$PrintServer\$Drive`$"))).VersionInfo.ProductVersion
$Sheet.Cells.Item($intRow,8) = Split-Path $Driver.DriverPath -Leaf
}
I don’t know Powershell with printers well enough to know how to fix the longer original line with the path which PS says does not work, therefore the ForEach loop does not work.
Using Get-PrinterDriver gets me all the other information including the driver name but I could not find how to get the additional driver information like the version and path.
Can anyone be willing to consider helping out??
Thank you, Tom