Mapping Network Printers Using PowerShell

A number of ways exist to map network printers, group policy being a primary method, but working for a place that has numerous printers, group policy is not flexible enough to fit the need.

If you go to the way back machine to the 1990's, Microsoft, as part of its resource kit for Windows NT 4.0 released a utility called "con2prt.exe". It worked great to map printers and set a default printer, but it with it being over 20 years old and better methods exist, it was time to update the script and retire con2prt.exe.

Microsoft has another utility method using "rundll32 printui.dll PrintUIEntry", this method was not only slow, it appeared to install the print driver when executed, even if the print driver was installed. I did not like this method.

That left the answer being powershell, which is not only fast, it does not need a 20 year old executable to run.

The command below will map a network printer, if you can multiple printers to map, you can call this command multiple times, specifying different printers.

(New-Object -ComObject WScript.Network).AddWindowsPrinterConnection("\\printerserver\Printer")

The command below will set a printer as the default printer.

(New-Object -ComObject WScript.Network).SetDefaultPrinter('\printerserver\Printer')

You just need to call the powershell script at login and it will map your printers.

As you can see it is very easy to write and does not require an NT 4.0 resource kit tool (which does work well).

I had to do some digging to find these commands, so I figured I would create a quick blog post to help others who might be attempting to modernize their print scripts.

TBJ Consulting

TBJ Consulting