Managing Printers With PowerShell

managing printers Power Shell instead of VBScript?

Sometimes it's necessary to add and remove specific printers to a computer. For example during a client deployment or when a user logs on. This post covers how to manage printers with Power Shell.

The following Power Shell commands are supported with Power Shell version 4 and newer. 

Installing a local network printer (without a printserver)

Installing a local printer consists of the following steps:

  1. Add the printer driver to your system's driverstore
  2. Install the printer driver from the driverstore
  3. Add a printer port to communicate with the printer
  4. Last but not least add the printer

Add the printer driver to your system's driverstore

Before you can install the printer driver you need to import the printer driver to your system's driverstore.

This can be achieved with the built in Windows "pnputil" utility.

The following code adds all drivers from the specified path to the driverstore:

Install the printer driver from the driverstore

This step is quite simple, you just need to know the name of the printer driver you want to install. For example "HP Universal Printing PCL 6".

Hint: To get the name of a driver you can check the "[strings]" section of your *.inf file.

Add a printer port to communicate with the printer

As a best practise i recommend to use the printer ip address or hostname as port name.

Add the printer

Finally add the printer with the created port and driver and the specified name

Installing a printer from a printserver

Installing a printer from a printserver is quite simple. You just need the hostname or ip address of the printserver and the shared name for the printer.

Setting a default printer

To set a default printer the printer must already be installed to your machine.

Windows 10 uses by default the last chosen printer as default

If you need to specify a persistent default printer you can disable this feature with the following registry key:

Thanks for reading my very first blog post. Hopefully you are able to start "managing printers the power shell way" .You can find more information on the About section of my blog. Stay tuned.

Reference:

 

Nicola

The guy behind this blog. Combining work sports and social life.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.