Using PowerShell to install a network printer
Installing a new network printer using Windows PowerShell involves performing the following steps:
Installing a printer driver for the new printer
Creating a Standard TCP/IP Port for the printer
Installing the printer using the driver and port specified
Performing any additional configuration needed for the printer
For example, let’s say you want to install a printer that uses the Dell Color Laser PCL6 Class Driver on your print server. You could begin by using the Add-PrinterDriver cmdlet to install the printer driver on the server:
PS C:\> Add-PrinterDriver -ComputerName HOST7 -Name "Dell Color Laser PCL6 Class Driver"
Next, you could use the Add-PrinterPort cmdlet to add a new port for the printer like this:
PS C:\> Add-PrinterPort -ComputerName HOST7 -Name "172.16.11.63" `
Next, you could use the Add-Printer cmdlet to install, name, and share the new printer using the driver and port previously specified as follows:
PS C:\> Add-Printer -ComputerName HOST7 -Name "Sales Printer" `
-DriverName "Dell Color Laser PCL6 Class Driver" -Shared `
-ShareName "SalesPrint" -PortName "172.16.11.63"
Finally, you might want to change the default paper size for the new printer from Letter to Legal like this:
PS C:\> Set-PrintConfiguration -ComputerName HOST7 -PrinterName "Sales Printer" `
The above tip was excerpted from Mitch Tulloch's book Training Guide: Installing and Configuring Windows Server 2012 from Microsoft Press.
Mitch is a nine-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows administration, deployment and virtualization. For more information see http://www.mtit.com.