List printers and IP addresses on a windows server using powershell

From roonics
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The below will list all printers on the server and its IP address:

# Collect port names and host addresses into hash table
$hostAddresses = @{}
Get-WmiObject Win32_TCPIPPrinterPort | ForEach-Object {
  $hostAddresses.Add($_.Name, $_.HostAddress)
}

Get-WmiObject Win32_Printer | ForEach-Object {
  New-Object PSObject -Property @{
    "Name" = $_.Name
    "DriverName" = $_.DriverName
    "Status" = $_.Status
    "HostAddress" = $hostAddresses[$_.PortName]
    
  }
}

Example output:

DriverName                               Name                          HostAddress
----------                               ----                          -----------
Xerox WorkCentre 7855                    Printer01                     10.10.10.10
Xerox WorkCentre 7220                    Printer02                     10.10.10.20
HP Color LaserJet CP202X PS Class Driver Printer03                     10.10.10.30
Microsoft XPS Document Writer v4         Microsoft XPS Document Writer
Microsoft Print To PDF                   Microsoft Print to PDF

‎<comments />