Installing Local Printer

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell


WMI represents all locally installed printers with its class Win32_Printer, so you can easily look what's installed:

PS> Get-WmiObject -Class Win32_Printer | Select-Object -Property *

To add a new local printer, just add a new instance of Win32_Printer. The example adds a new local printer and shares it over the network (provided you have sufficient privileges and the appropriate printer drivers):

$printerclass = [wmiclass]'Win32_Printer'
$printer = $printerclass.CreateInstance()
$printer.Name = $printer.DeviceID = 'NewPrinter'
$printer.PortName = 'LPT1:'
$printer.Network = $false
$printer.Shared = $true
$printer.ShareName = 'NewPrintServer'
$printer.Location = 'Office 12'
$printer.DriverName = 'HP LaserJet 3050 PCL5'

To find out what the properties are that you must set for a given printer, simply install the printer manually on a test system, then query the installed printer with the line above.

This will dump all the properties like driver name etc. that you need to set to install the printer via script.

Twitter This Tip! ReTweet this Tip!

Posted Feb 08 2013, 06:00 AM by ps1


BiggRedd wrote re: Installing Local Printer
on 07-18-2013 2:31 PM

Like this information - very hard to find info on adding/renaming printers and printer/drivers for Windows 7 using Powershell.  This is the first thing I've found that works.  

A couple questions - how to I get the properties for a specific printer using the Get-WmiObject command you first listed?

And in adding a new local printer, what if I have a .inf file instead of a Driver Name?

Copyright 2012 All rights reserved.