Retrieve a list of print queues from a Windows server including queue name, share name, driver, printer port and network connectivity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$colComputer = "Server001" | |
$objOut = @() | |
foreach ($objComputer in $colComputer) { | |
$colPrinter = Get-WmiObject win32_printer -ComputerName $objComputer | |
foreach ($objPrinter in $colPrinter) { | |
if ($objPrinter.Name -notlike "Microsoft XPS Document Writer") { | |
$objPing = "Ping Succeeded" | |
try { | |
$objTest = Test-Connection -ComputerName $objPrinter.PortName -count 1 -ErrorAction Stop | |
} catch { | |
$objPing = "Ping Failed" | |
} | |
$objOut += [PSCustomObject] @{ | |
"Server" = $objPrinter.SystemName | |
"Name" = $objPrinter.Name | |
"Location" = $objPrinter.Location | |
"Share Name" = $objPrinter.Sharename | |
"IP Address" = $objPrinter.PortName | |
"Driver" = $objPrinter.DriverName | |
"Ping Result" = $objPing | |
} | |
} | |
} | |
} | |
$objOut | export-csv "D:\Reports\Printer.csv" -NoTypeInformation |