Powershell – Exploring Printer commands using Powershell

0

Welcome Back,

I was recently asked to fetch the printer details on the Print server, while doing so I thought of writing this article so that it can benefit everyone else. Hence I have titled this article as Exploring Printer commands using Powershell.

There are various ways of achieving this. Since in my environment I was stuck with Powershell v2.0, I was to make do with the Get-WmiObject cmdlet.

But if you have Windows Server 2012 R2 or you are running RSAT tool on Windows 8.1, you have the new Powershell cmdlets that were introduces with Powershell v4.0.

You can find the Printer Management module cmdlets here.

Moving on, like I said earlier we will be using WMI Objects to query the server and the class that we use for the below example is Win32_Printer.

The below example will list all the printers on the Print Server and we are selecting Name, DriverName, PortName, ShareName to see the output clearly in a table form.

Get-WmiObject Win32_Printer -ComputerName PrintServer `
| Sort-Object Name `
| Select-Object Name, DriverName, PortName, ShareName

Notice the back tick after everyone (Found below the Esc key), it tells Powershell that the command is continuing to the next line.

In the next example, let us say that we want to list all the Printer drivers on the print server.

Get-WmiObject -Class Win32_PrinterDriver -ComputerName PrintServer `
| Sort-Object Name `
| Select-Object Name, DriverPath

Notice that we have changed only the WMI class as Win32_PrinterDriver.

Now, I just want to list a specific Printer from the Print server.

Get-WmiObject Win32_Printer -ComputerName PrintServer -Filter "Name='Xerox Printer'"

The below code will display a specific Printer Driver on the server.

Get-WmiObject Win32_PrinterDriver -ComputerName PrintServer -Filter "Name='Xerox Printer'

I hope this will help you and you found this informative, thank you for reading!

Share.

About Author

I am Adil Arif, working as a Senior Technical Support Engineer at Rubrik as well as an independent blogger and founder of Enterprise Daddy. In my current role, I am supporting infrastructure related to Windows and VMware datacenters.

Leave A Reply