Skip to content
Printers Setup
Menu

Computers

Add a Printer with PowerShell: Port, Driver and Queue

Written by Printers Setup Editorial Team · Updated

A person working at a computer on a home desk
Photo: Shixart1985, CC BY 2.0, via Wikimedia Commons

The Settings app is fine for one printer on one PC. When you set up several computers, want a repeatable script, or Settings simply cannot find the printer, it is faster to add a printer with PowerShell. Windows 11 includes the PrintManagement module, so there is nothing to install. This guide walks through the three building blocks, driver, port and printer, with commands you can copy and adapt.

What you need first

  • The printer’s IP address. Print the printer’s network configuration page or check your router. Our guide to finding a printer’s IP address shows all the methods. Reserve that address in the router so it does not change later.
  • A driver. Either a driver Windows already has, or the maker’s driver package unpacked to a folder with an .inf file in it. Our Windows 11 driver guide explains the choice.
  • An administrator PowerShell. Right-click Start and choose Terminal (Admin).

Step 1: see what is already there

Start by looking, so you do not create duplicates:

Get-Printer | Select-Object Name, DriverName, PortName
Get-PrinterDriver | Select-Object Name
Get-PrinterPort | Select-Object Name, PrinterHostAddress

Get-Printer lists the printers on the computer. If the driver you need is already in the Get-PrinterDriver list, skip to Step 3.

Step 2: stage and install the driver

Add-PrinterDriver installs a driver that is already in the Windows driver store; it does not download anything. Microsoft’s example is simply Add-PrinterDriver -Name "Driver Name", and the cmdlet needs administrator credentials.

If the driver came from the printer maker, add its .inf file to the driver store first with Microsoft’s pnputil tool:

pnputil -i -a "C:\Drivers\ExamplePrinter\example.inf"
Add-PrinterDriver -Name "Example Printer Driver"

The -Name must match the model name inside the .inf file exactly, including spaces and capitals. If you are not sure of the name, open the .inf in Notepad and look at the model lines, or run printui /s, open the Drivers tab and choose Add to browse the names. Microsoft’s printui documentation also lists /ia for installing a driver from an .inf file, if you prefer that tool.

Step 3: create a TCP/IP port

A network printer needs a port that points at its address. Microsoft’s example creates one with -PrinterHostAddress:

Add-PrinterPort -Name "IP_192.168.1.20" -PrinterHostAddress "192.168.1.20"

The port name is just a label. Naming it after the address makes it easy to recognise later. According to Microsoft’s documentation, Add-PrinterPort does not need administrator credentials, and it can also create LPR ports if your printer needs them.

Step 4: add the printer

Now join the three pieces:

Add-Printer -Name "Office Printer" -DriverName "Example Printer Driver" -PortName "IP_192.168.1.20"

-Name is what people will see in print dialogs, so choose something clear such as “Upstairs Laser”. Run Get-Printer again to confirm it is listed.

Connecting to a shared printer instead

If the printer is shared from another computer or a print server, you do not need a port or a local driver step. Microsoft’s second Add-Printer example connects in one line:

Add-Printer -ConnectionName "\\PrintServer\Office Printer"

The share must already be set up on the other machine; our printer sharing guide covers that, and a Raspberry Pi print server works as the host too.

Step 5: set as default and test

Windows 11 can manage the default printer automatically. If you want this printer to be the fixed default, turn off Let Windows manage my default printer first, as explained in set a default printer in Windows 11. Microsoft’s printui tool can then set the default and print a test page from the same window:

rundll32 printui.dll,PrintUIEntry /y /n "Office Printer"
rundll32 printui.dll,PrintUIEntry /k /n "Office Printer"

In Microsoft’s printui documentation, /y sets the printer as the default and /k prints a test page. Our test page guide shows what to look for on the page.

Default print settings

The Set-PrintConfiguration cmdlet changes defaults such as duplex and colour for a printer, for example Set-PrintConfiguration -PrinterName "Office Printer" -DuplexingMode TwoSidedLongEdge. Not every driver supports every option. If you prefer clicking, see change default print settings in Windows 11.

A reusable script for several PCs

Once the commands work on one computer, save them as a .ps1 file and run it on the others. A simple pattern checks before it creates anything, so running it twice does no harm:

$ip = "192.168.1.20"
$port = "IP_$ip"
$driver = "Example Printer Driver"
$name = "Office Printer"
if (-not (Get-PrinterDriver -Name $driver -ErrorAction SilentlyContinue)) { Add-PrinterDriver -Name $driver }
if (-not (Get-PrinterPort -Name $port -ErrorAction SilentlyContinue)) { Add-PrinterPort -Name $port -PrinterHostAddress $ip }
if (-not (Get-Printer -Name $name -ErrorAction SilentlyContinue)) { Add-Printer -Name $name -DriverName $driver -PortName $port }

The driver still has to be in each PC’s driver store, so copy the driver folder and run the pnputil line first on machines that do not have it. Microsoft’s documentation notes that these cmdlets also accept a -ComputerName parameter and work in a PowerShell remoting session, which lets you set up a remote PC without walking over to it. Your organisation’s script execution policy may block unsigned scripts; on a work PC, ask IT before changing it.

Running without administrator rights

Most of the commands on this page change system-wide settings. Staging a driver with pnputil, Add-PrinterDriver and Add-PrinterPort need an elevated PowerShell window (right-click, Run as administrator). Connecting to a shared printer with Add-Printer -ConnectionName is a per-user connection, but Windows Point and Print rules can still require an administrator if the print server would have to install a driver. If you are on a managed PC without admin rights, our guide to installing a printer without admin rights explains what you can do yourself and what to ask IT for.

Scripts and Windows protected print mode

If a PC has Windows protected print mode turned on, third-party drivers cannot be installed, so a script that stages a maker’s driver will fail on that PC. Printers that are Mopria certified can still be added: Windows uses its own built-in printing for them. Check whether the mode is on before deploying a script to several PCs; our guide to Windows protected print mode shows where to look. Arm-based PCs raise a similar question, since a driver package must include Arm64 support; see printers on Windows 11 Arm PCs.

Common errors

  • “The specified driver does not exist in the driver store”: the .inf was not staged, or the name does not match. Repeat Step 2.
  • Access denied: PowerShell is not running as administrator.
  • Printer added but jobs fail: check the IP address on the port with Get-PrinterPort, and that the computer can reach that address.

To undo everything, see remove a printer in Windows 11, which covers Remove-Printer and Remove-PrinterDriver. The point-and-click route is in add a printer in Windows 11.

Frequently asked questions

Do I need administrator rights to add a printer with PowerShell?

For drivers, yes: Microsoft's documentation says Add-PrinterDriver needs administrator credentials. Add-PrinterPort does not, and Add-Printer may need them depending on the printer and driver. Running Terminal as administrator avoids surprises.

Where do I get the driver name for Add-PrinterDriver?

It is the model name inside the driver's .inf file. After adding the .inf with pnputil, the name usually appears in the printer list in the Add printer driver wizard, or you can open the .inf file in Notepad and look for the model lines. It must match exactly.

Can I add a printer on another computer?

Yes. The print management cmdlets accept a -ComputerName parameter, and Microsoft notes they can be used in a PowerShell remoting session. The remote computer still needs the driver in its driver store.

How do I undo it?

Use Remove-Printer with the printer name, then Remove-PrinterDriver and, if you want, Remove-PrinterPort. Our guide to removing a printer in Windows 11 covers the order.

Sources

PS

Printers Setup Editorial Team

Editorial team

The Printers Setup team writes and reviews step-by-step printer setup guides and checks them against the current menus of Windows, macOS, ChromeOS, iOS and Android.

Related guides