How to Install and Remove Printer with PowerShell on Windows

Author: Peter Barnett           Date: Jan 03, 2020

Sometimes there are situations that when removing the printer from the system, you may encounter a lot of errors. The printer may refuse to be deleted, or deleted not completely, the new driver refuses to be installed, and after installation, instead of working printing, it gives an error like The driver is not fully installed, and some printing functions will be unavailable. Nevertheless, there is no need to panic in this situation, there is always the possibility to format the hard disk of the computer, install the operating system and all associated software. Today, we will look at typical commands for managing printers, ports, and print drivers in Windows using PowerShell. These methods of managing printers can be used in modern operating systems - Windows 10, 8.1 and Windows Server 2012 R2 / 2016/2019 to add or remove network printer
Use Action1 to add or remove network printer:

Fully functional for 50 endpoints, never expires. More details >

Let's Get Acquainted with Powershell Module: Printmanagement

Along with the release of Windows 8.1 and Windows Server 2012 R2, Microsoft released a new version of PowerShell 4.0 (included in the Windows Management Framework 4.0), which significantly expanded the list of cmdlets for managing a Windows-based print server. A complete list of cmdlets for managing printers, drivers, and print queues available in the PrintManagement module on Windows 10 (PoSh v5) can be displayed with the command:

Get-Command –Module PrintManagement

Step 1 to Work With Remote Network Printer is to use command Get Command Module PrintManagement

There are 22 PowerShell cmdlets in the PrintManagement module for managing printers, drivers, print ports, and queues:

  • Add-Printer - add (install) a new printer;
  • Add-PrinterDriver - install a new print driver;
  • Add-PrinterPort - create print port;
  • Get-PrintConfiguration - print printer settings;
  • Get-Printer - display the list of printers installed on the computer;
  • Get-PrinterDriver - list the installed print drivers;
  • Get-PrinterPort - display a list of print ports;
  • Get-PrinterProperty - show printer properties;
  • Get-PrintJob - get a list of printer print jobs;
  • Read-PrinterNfcTag - get printer information from an NFC tag;
  • Remove-Printer - remove the printer;
  • Remove-PrinterDriver - remove printer driver;
  • Remove-PrinterPort - remove printer port;
  • Remove-PrintJob — delete a print job on a printer;
  • Rename-Printer - rename the printer;
  • Restart-PrintJob - restart the print job;
  • Resume-PrintJob - run a paused task
  • Set-PrintConfiguration - printer configuration settings;
  • Set-Printer - update printer configuration;
  • Set-PrinterProperty - change printer properties;
  • Suspend-PrintJob - suspend the print job;
  • Write-PrinterNfcTag - write information to the NFC tag.

Detailed information on the syntax of a specific command can be obtained as follows:

Get-Help cmdlet-name -Detailed

Examples of using commands:

Get-Help cmdlet-name -Examples

Let's look at a few examples of typical printer management scripts in Windows 10 from PowerShell.

Installing a Print Driver in the Driver Store

To list the print drivers that are installed in the Windows driver store:


Next step to Work With Remote Network Printer is to use command Get PrinterDriver

Let us set a new print driver in the system, for example, HP Universal Printing PCL 6. According to the documentation, the PowerShell command for adding a driver should be like this:

Add-PrinterDriver -Name "HP Universal Printing PCL 6" -InfPath "C:\Distr\HP-pcl6-x64\hpcu118u.inf"

However, when trying to install a driver in this way, an error appears:

Add-PrinterDriver : One or more specified parameters for this operation has an invalid value.
At line:1 char:1
+ Add-PrinterDriver -Name "HP Universal Printing PCL 6" -InfPath "C:\Di ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MSFT_PrinterDriver:ROOT/StandardCimv2/MSFT_PrinterDriver) [Add-PrinterDriver], CimException + FullyQualifiedErrorId : HRESULT 0x80070057,Add-PrinterDriver

It turns out that the driver from the inf file can be added only if it is already in the DriverStore driver storage. It turns out that using the Add-PrinterDriver command to install a driver that is not available in the system driver storage is impossible. To install the driver in the DriverStore, you can use:

  • The pnputil.exe utility. The format is pnputil.exe -i -a C: \ Distr \ HP-pcl6-x64 \ hpcu118u.inf (install a specific printer driver) or pnputil.exe -i -a C: \ Distr \ HP-pcl6-x64 \ * .inf (installs all drivers found in the inf files of the specified directory);

    Next step to Work With Remote Network Printer is to using utility pnputil

  • The Add-WindowsDriver cmdlet that allows you to integrate drivers into an offline Windows image.

After adding a printer driver to the repository, you need to add it to the list of available print servers.

Add-PrinterDriver -Name "HP Universal Printing PCL 6"

use cmdlt Add PrinterDriver Name

Installing a New Printer Using Powershell

Let's create an ip port for printing on a network printer (here you can specify both the IP address of the network printer and the name of the remote print server):

Add-PrinterPort -Name "IP_192.168.10.26" -PrinterHostAddress ""

Before adding a port, you can check if it exists:

$portName = "IP_192.168.10.26"
$checkPortExists = Get-Printerport -Name $portname -ErrorAction SilentlyContinue
if (-not $checkPortExists) {
Add-PrinterPort -name $portName -PrinterHostAddress "" }

With the help of the following command we will create a new printer in the system and publish it (open shared access to it):

Add-Printer -Name hp2050_Office1_Buh -DriverName "HP Deskjet 2050 J510 series Class Driver" -PortName IP_192.168.10.26 -Shared -ShareName "hp2050_1_BUh" –Published

After executing the specified commands, a new shared printer will appear in the system under the name hp2050_Office1_Buh.

appear new printer buh

Listing Printers on a Print Server Using Powershell

Let's display the full list of printers installed on this computer:


As you can see, the command shows the name of the printer, the type (local or network), the driver, the print port, whether the printer is shared and whether the printer is published to AD.

Listing Printers on a Print Server Using Powershell

Most PrintManagement cmdlets can be used to view the status and manage printers, drivers, and print queues on remote computers. The name of the remote computer or server is specified as an argument to the –ComputerName parameter.

Using PowerShell you can get information about installed printers on a remote computer (print server), to do this, run the command:

Get-Printer -ComputerName msk-prnt1 | Format-List Name,DriverName

To display only a list of shared printers, use the command:

Get-Printer -ComputerName msk-prnt1 | where Shared -eq $true | fl Name

Connect a Network Printer from Powershell

To connect a printer from a print server, use the command:

Add-Printer -ConnectionName \\msk-prnt1\HPCL3020

Windows 10 uses the latest printer that was printed as the default printer, if you want to use a fixed default printer, run the command:

Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name "LegacyDefaultPrinterMode" -Value 1 –Force

To set the default printer, use the following commands:

$wsnObj = New-Object -COM WScript.Network


Remove Network Printer Using Powershell

To remove a printer, you need to run the following PowerShell command:

Remove-Printer -Name "hp2050_Office1_Buh"

You can remove a specific driver using the Remove-PrinterDriver cmdlet:

Remove-PrinterDriver -Name "HP Universal Printing PCL 6"

Consider using Action1 to add or remove network printer if:

  • - You need to perform an action on multiple computers simultaneously.
  • - You have remote employees with computers not connected to your corporate network.

Action1 is a cloud-based platform for patch management, software deployment, remote desktop, software/hardware inventory, endpoint management and endpoint configuration reporting.


Start your free trial or use free forever to manage up to 50 endpoints. More details >

Relevant How To Articles and Action1 Features:

By continuing to use our website, you agree with our use of cookies in accordance with our Privacy Policy. You can reject cookies by changing your browser settings.     
Ok, got it