In this article, I will explain how to get printer IP address and other printer properties like Portname, model, driver name, and printer status in PowerShell.
Using PowerShell, the Get-Printer cmdlet, printer IP address, and printer status can be easily retrieved. The PortName contains the printer’s IP address.
Let’s understand using the Get-Printer cmdlet with different examples to get a printer IP address, printer status, and printer location.
PowerShell Get Printer IP Address and Name
To get the printer IP address, and name using PowerShell, use the Get-Printer command.
Get-Printer | select Name,PortName,DriverName | Export-Csv D:\Printers.csv -NoTypeInformation
In the above example, the PowerShell Get-Printer
command list all the printer on the computer and pipes the result to the Select command. The Select
command selects the properties such as Name, PortName, and DriverName. Lastly, the printer IP address and name are sent to the Export-CSV cmdlet to export information to the printers.csv file on the D drive.
The output of the above PowerShell script gets the printer’s IP address and name.
PS D:\> Get-Printer | select Name,PortName,DriverName
Name PortName
---- --------
\\incorp-eu-01\Printer_HP 127.0.0.1_4,127.0.0.1_5,127.0.0.1_6,127.0.0.1_7
\\incorp-eu-02\Printer_HP 10.229.18.19
Do you know: How to get printer properties in PowerShell!
PowerShell Get Printer Location and status
To get printer location and status using PowerShell, use the below command
Get-Printer | Select Name,Location,PrinterStatus | Out-GridView
In the above example, using Get-Printer, it retrieved the printer name, printer location, and the printer status, and displayed printer information in the format list.
Using Get-WmiObject to get Printer PortName, Status
Using the PowerShell Get-WmiObject
cmdlet with class win32_printer
, it gets printer status, printer location, and printer portname.
Get-WmiObject -class win32_printer -ComputerName CORP-IN-18 | Select Caption,Location,PortName,DriverName,PrinterStatus | Out-GridView
In the above example, the Get-WmiObject cmdlet gets printer list installed on a specified computername (local machine or remote machine) and gets the printer IP address, and printer location in grid view format.
Do you know: How to use erroraction or errorvariable parameters in PowerShell!
Conclusion
I hope the above article about how to get printer IP address and printer status, other printer information can be easily retrieved using the Get-Printer cmdlet in PowerShell.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.
Thanks, Powershell worked, very easy from Print Server