In previous tips we looked at how you can use Get-PrinterProperty to read printer properties for locally installed printers. This cmdlet is part of the PrintManagement module which ships with all Windows operating systems.
Important: Since property names are print driver specific, this cmdlet can be awesome if you need to manage the same types of printers throughout your enterprise. It is not a first choice if you want to create detailed printer inventories for a large number of different printer types as you would have to identify the exact property names for each printer driver in use. Likewise, in the below examples make sure you replace the printer property names with those that are supported by your printers.
In a nutshell, to read a particular printer property, you provide the name of the printer (run Get-Printer to find out printer names). The cmdlet then lists all available printer properties which again may vary depending on printer driver and model:
PS> Get-PrinterProperty -PrinterName 'S/W Laser HP' ComputerName PrinterName PropertyName Type Value ------------ ----------- ------------ ---- ----- S/W Laser HP Config:AccessoryO... String 500Stapler S/W Laser HP Config:ActualCust... String 431800_914400 S/W Laser HP Config:AutoConfig... String NotInstalled S/W Laser HP Config:Auto_install String INSTALLED S/W Laser HP Config:BookletMak... String NOTINSTALLED S/W Laser HP Config:CombineMed... String Installed S/W Laser HP Config:DeviceIsMo... String Installed S/W Laser HP Config:DuplexUnit String Installed
You could then for example filter property names and get a list of installed and uninstalled printer accessories:
PS> Get-PrinterProperty -PrinterName 'S/W Laser HP' | Where-Object Value -like *installed* | Select-Object -Property PropertyName, Value PropertyName Value ------------ ----- Config:AutoConfiguration NotInstalled Config:Auto_install INSTALLED Config:BookletMakerUnit_PC NOTINSTALLED Config:CombineMediaTypesAndInputBins Installed Config:DeviceIsMopier Installed Config:DuplexUnit Installed Config:EmbeddedJobAccounting NotInstalled Config:EnvFeed_install NOTINSTALLED Config:HPJobSeparatorPage NotInstalled Config:HPPinToPrintOnly NotInstalled Config:HPPunchUnitType NotInstalled Config:InsLwH1_install NOTINSTALLED Config:InsUpH1_install NOTINSTALLED Config:JobRetention Installed Config:ManualFeed_install INSTALLED Config:PCCFoldUnit NOTINSTALLED Config:PCVFoldUnit NOTINSTALLED Config:PrinterHardDisk Installed Config:SecurePrinting Installed Config:StaplingUnit_PC NOTINSTALLED Config:Tray10_install NOTINSTALLED Config:Tray1_install INSTALLED Config:Tray2_install INSTALLED Config:Tray3_install INSTALLED Config:Tray4_install NOTINSTALLED Config:Tray5_install NOTINSTALLED Config:Tray6_install NOTINSTALLED Config:Tray7_install NOTINSTALLED Config:Tray8_install NOTINSTALLED Config:Tray9_install NOTINSTALLED Config:TrayExt1_install NOTINSTALLED Config:TrayExt2_install NOTINSTALLED Config:TrayExt3_install NOTINSTALLED Config:TrayExt4_install NOTINSTALLED Config:TrayExt5_install NOTINSTALLED Config:TrayExt6_install NOTINSTALLED
Once you know printer name and a particular property name, you can query individual properties and retrieve the value to use it in your scripts. Here is an example to check whether a duplex unit is installed or not (make sure you adjust printer name and property name to your printer model):
PS> Get-PrinterProperty -PrinterName 'S/W Laser HP' -PropertyName Config:DuplexUnit | Select-Object -ExpandProperty Value Installed PS> $hasDuplexUnit = (Get-PrinterProperty -PrinterName 'S/W Laser HP' -PropertyName Config:DuplexUnit).Value -eq 'installed' PS> $hasDuplexUnit True
To query printers remotely, Get-PrinterProperty has the -ComputerName parameter. It accepts a single string so you can only query one printer at a time, and there is no -Credential parameter so you cannot authenticate as someone else. You could try this though to query your own machine, and once that works, replace the computer name with a real remote system:
PS> Get-PrinterProperty -PrinterName 'S/W Laser HP' -ComputerName $env:COMPUTERNAME
Since the cmdlet uses Windows Remote Management service for remote access, the target print server should have WinRM remoting enabled (which is the default for Windows Servers), and you should be Administrator on the target side.
For all practical uses, you also want to be able to query multiple servers and authenticate as someone else. For remote access, use New-CimSession first to specify all servers you’d like to query, and submit a credential if you want.
Next, submit this session to Get-PrinterProperty. Provided you have appropriate access, all servers in your session are now queried in parallel which saves a lot of time. The -ThrottleLimit parameter determines how many sessions are actually contacted at a maximum. If you specified more servers than the number of maximum connections, PowerShell will automatically queue the rest:
$session = New-CimSession -ComputerName server1, server2, server3 -Credential mydomain\remotinguser Get-PrinterProperty -PrinterName 'S/W Laser HP' -CimSession $session -ThrottleLimit 100 Remove-CimSession -CimSession $session
Extra Tip: You can use Get-Printer to find out remote printer names as well. Get-Printer also accepts the -CimSession parameter so you can use the same network session to query all printer names from one or more remote servers.