PowerShell add printer builder
Add a printer with PowerShell
Type the printer's IP address, or its print server and share, and get one script for Windows 10 or 11 that adds the port, the driver and the printer, sets double-sided and black and white, and the line that takes it off again. It runs in your browser: nothing you type is sent to us.
Paste this in PowerShell
Search Start for PowerShell, right-click it and choose Run as administrator, then paste the whole script.
if (-not (Get-PrinterPort -Name 'IP_10.20.1.22' -ErrorAction SilentlyContinue)) { Add-PrinterPort -Name 'IP_10.20.1.22' -PrinterHostAddress '10.20.1.22' -PortNumber 9100 }
Add-PrinterDriver -Name 'Microsoft PCL6 Class Driver'
Add-Printer -Name 'Copy Room Colour' -DriverName 'Microsoft PCL6 Class Driver' -PortName 'IP_10.20.1.22'
Set-PrintConfiguration -PrinterName 'Copy Room Colour' -DuplexingMode TwoSidedLongEdge -Color $false -PaperSize Letter
Get-Printer -Name 'Copy Room Colour' | Format-List Name,DriverName,PortName,PrinterStatus- 1A standard TCP/IP port to 10.20.1.22 on port 9100, named the way Windows names it, unless it is there already.
- 2Installs a class driver that comes with Windows: it prints, but without the model's finishing options.
- 3Adds Copy Room Colour on that port. It is on this computer for everyone who signs in.
- 4Prints double-sided on the long edge, black and white, on Letter unless someone picks otherwise in the print dialog. The printer needs a duplex unit for two-sided.
- 5Shows the printer, its driver and port, to check it worked.
To take it off, and other ways in
The undo
Remove-Printer -Name 'Copy Room Colour'; Remove-PrinterPort -Name 'IP_10.20.1.22'Takes the printer and its port off again.
What each cmdlet does
All of them come with Windows 10 and 11, in the PrintManagement module. The IP route prints to the printer's port 9100; the server route goes through a print server, which hands each computer the driver.
| Cmdlet | What it does |
|---|---|
| Add-PrinterPort | Makes a standard TCP/IP port: the printer's address and port 9100. -PrinterHostAddress takes an IP address or a hostname. |
| Add-PrinterDriver | Installs a driver that is already in the Windows driver store. It does not download one. |
| Add-Printer | Joins a name, a driver and a port into a printer. With -ConnectionName it connects to a shared printer on a server instead. |
| Set-PrintConfiguration | Sets the printer's defaults: -DuplexingMode, -Color and -PaperSize. People can still change them in the print dialog. |
| Get-Printer | Lists printers. Get-Printer | Format-Table Name,DriverName,PortName shows what is there now. |
| Remove-Printer | Takes a printer off. Remove-PrinterPort then removes its port, once nothing uses it. |
Which driver?
A print driver turns the page into the printer's language. The Microsoft class drivers come with Windows and print plain jobs; the model's own driver adds its trays, staples and hole punch. A job that will not leave afterwards is cleared with the print queue clear command.
PCL6 or PS class
Most office copiers take PCL; pick PS for one that only speaks PostScript.
The model's driver
Unzip the maker's download, run pnputil /add-driver with its .inf file and /install, then use its exact name.
Exact names
Get-PrinterDriver lists the drivers installed, by the name Add-Printer needs.
The default printer
Windows 11 moves the default to the last one used unless Let Windows manage my default printer is off.
Take it further
- Printer IP address finderNot sure of the address? The command that lists every printer and the address behind it.
- Printer port checkerCheck the printer answers on port 9100 or 631 before you add it.
- IPP vs TCP/IP printingWhy this script uses a standard TCP/IP port, and when IPP is the better road.
- lp print command builderThe same job on a Mac or Linux machine: one lp line with copies, sides and paper set.
- lpadmin add printer builderAdding the printer to a Mac or Linux computer instead: one lpadmin line with IPP Everywhere.
Add the printer once, for every teacher.
This script adds one printer to one computer. In KyberCopy the copy room adds each printer once, the relay reads what it can do over IPP, and teachers send from the request form without a driver or a script on their laptop.
Book a demo