Skip to content

PowerShell Printing

How to manage printers, print documents, and handle print queues in PowerShell using native cmdlets like Get-Printer, Out-Printer, and Remove-PrintJob for Windows administration.

PowerShell provides native print management capabilities on Windows through the built-in PrintManagement module. System administrators can inspect connected physical and virtual printers, route text streams and documents directly to output trays, monitor print queues, cancel stalled print jobs, and provision new network printers, all without opening graphical management consoles like Devices and Printers.

Inspecting Printers with Get-Printer

The Get-Printer cmdlet enumerates physical and virtual print devices configured on the local system or on remote print servers.

Consolepowershell
Get-Printer
Outputplaintext
Name                           ComputerName    Type         DriverName                PortName        Shared   Published
----                           ------------    ----         ----------                --------        ------   ---------
Brother HL-L2350DW series                      Local        Brother HL-L2350DW ser... WSD-8f12b3c4... False    False
Microsoft Print to PDF                         Local        Microsoft Print To PDF    PORTPROMPT:     False    False
OneNote (Desktop)                              Local        Send to Microsoft OneN... nun001:         False    False

where:

  • Name identifies the printer as registered in Windows.
  • DriverName shows the print driver backing the device.
  • PortName indicates the communication port used.
  • Shared and Published reflect whether the printer is exposed on the network.
  • -ComputerName can be added to query printers installed on a remote machine over the network.

Filtering and Inspecting Device Properties

Filter to a specific printer using -Name, and inspect detailed operational status:

Consolepowershell
Get-Printer -Name "Microsoft Print to PDF" | Format-List -Property Name, DriverName, PortName, PrinterStatus, JobCount
Outputplaintext
Name          : Microsoft Print to PDF
DriverName    : Microsoft Print To PDF
PortName      : PORTPROMPT:
PrinterStatus : Normal
JobCount      : 0

To identify the system's active default printer, query the CIM class Win32_Printer:

Consolepowershell
Get-CimInstance -ClassName Win32_Printer | Where-Object { $_.Default -eq $true } | Select-Object Name, PortName, DriverName
Outputplaintext
Name                      PortName         DriverName
----                      --------         ----------
Brother HL-L2350DW series WSD-8f12b3c4...  Brother HL-L2350DW series

Printing Documents and Output Streams

PowerShell supports two primary techniques for printing: sending text streams directly to a printer using Out-Printer, and opening document files via their registered Windows shell handlers with Start-Process -Verb Print.

Streaming Pipeline Text with Out-Printer

The Out-Printer cmdlet redirects standard pipeline output (Stream 1) directly to a specified printer. If no printer is explicitly specified using -Name, output is sent to the system's default printer.

print-service-summary.ps1powershell
Get-Service | 
    Where-Object { $_.Status -eq "Running" } | 
    Format-Table -Property Name, DisplayName, StartType | 
    Out-Printer

where:

  • Get-Service collects service objects from the local machine.
  • Where-Object isolates running services.
  • Format-Table converts the objects into visual columnar text before transmission.
  • Out-Printer transmits the formatted text stream to the default Windows printer.

You can also target a specific printer with -Name:

Consolepowershell
Get-Content "C:\Reports\summary.txt" | Out-Printer -Name "HP LaserJet Pro M404"

Printing Complex Documents with Start-Process -Verb Print

Out-Printer converts incoming objects into plain text. It cannot render formatted documents such as PDFs, Word files (.docx), or images. To print compiled binary documents, call the native Windows print handler using Start-Process with the Print or PrintTo verb.

Consolepowershell
Start-Process -FilePath "C:\Reports\invoice.pdf" -Verb Print

To target a specific alternative printer without changing system defaults, use -Verb PrintTo with the printer name as an argument:

print-document.ps1powershell
$DocumentPath = "C:\Reports\QuarterlyAudit.pdf"
$TargetPrinter = "Brother HL-L2350DW series"

Start-Process -FilePath $DocumentPath -Verb PrintTo -ArgumentList "`"$TargetPrinter`"" -PassThru | Out-Null

where:

  • -FilePath specifies the document to print.
  • -Verb PrintTo instructs Windows to launch the associated application (e.g., Adobe Acrobat or Edge) in background print mode directed at a specific device.
  • -ArgumentList passes the target printer name enclosed in escaped quotation marks.

Managing Print Queues and Spooler Jobs

When a document is sent to a printer, the Windows Print Spooler service (Spooler) creates a print job in that device's queue. PowerShell allows administrators to inspect, pause, restart, and remove these spooler jobs.

Querying Jobs with Get-PrintJob

The Get-PrintJob cmdlet inspects the documents currently waiting in a printer's queue:

Consolepowershell
Get-PrintJob -PrinterName "Brother HL-L2350DW series"
Outputplaintext
Id    ComputerName    PrinterName               DocumentName       DataType    JobStatus
--    ------------    -----------               ------------       --------    ---------
12                    Brother HL-L2350DW ser... QuarterlyAudit.pdf RAW         Printing
13                    Brother HL-L2350DW ser... ServerInventory... RAW         Spooling

where:

  • Id uniquely identifies each queued job on that printer.
  • JobStatus shows the current state (Spooling, Printing, Error, Paused).

Removing Print Jobs with Remove-PrintJob

If a print job is stalled or corrupted, delete it using Remove-PrintJob, identified by its printer name and job ID:

Consolepowershell
Remove-PrintJob -PrinterName "Brother HL-L2350DW series" -ID 12

To cancel every pending job on a printer at once, pipe Get-PrintJob directly into Remove-PrintJob:

Consolepowershell
Get-PrintJob -PrinterName "Brother HL-L2350DW series" | Remove-PrintJob

To clear all pending print jobs across all local queues simultaneously:

Consolepowershell
Get-Printer | ForEach-Object {
    Get-PrintJob -PrinterObject $_ | Remove-PrintJob
}

Adding and Removing Printers

Configuring local or shared enterprise network printers is handled using Add-Printer, Add-PrinterPort, and Remove-Printer.

Connecting to a Shared Network Printer

To connect a client computer to a network printer hosted on a Windows print server:

Consolepowershell
Add-Printer -ConnectionName "\\PrintServer01\Finance-LaserJet"

where -ConnectionName specifies the UNC path to the shared network print resource.

Creating a Local TCP/IP Port and Adding a Printer

Provisioning a direct network printer with its own IP address requires configuring a printer port and driver first:

provision-network-printer.ps1powershell
Add-PrinterPort -Name "IP_192.168.10.45" -PrinterHostAddress "192.168.10.45"

Add-Printer -Name "Warehouse-Label-Printer" `
            -DriverName "Generic / Text Only" `
            -PortName "IP_192.168.10.45"

where:

  • Add-PrinterPort creates a TCP/IP communication socket at port 9100 pointing to the printer's network address.
  • Add-Printer binds the port, an installed driver name, and a friendly name together into a functional device.

Removing a Printer

To delete a printer mapping or unbind a device:

Consolepowershell
Remove-Printer -Name "Warehouse-Label-Printer"

Practical Example: Automated Print Spooler Queue Health Audit

The following script scans all printers configured on the host, inspects their queues for stalled or erroring jobs, calculates queue backlogs, and outputs a structured health summary:

audit-print-spooler.ps1powershell
$Printers = Get-Printer

$QueueReport = foreach ($Printer in $Printers) {
    $Jobs = Get-PrintJob -PrinterObject $Printer -ErrorAction SilentlyContinue

    $StalledJobs = $Jobs | Where-Object { $_.JobStatus -match "Error|UserIntervention|Offline" }

    [PSCustomObject]@{
        PrinterName    = $Printer.Name
        Driver         = $Printer.DriverName
        Port           = $Printer.PortName
        Shared         = $Printer.Shared
        PendingJobs    = ($Jobs.Count)
        StalledJobs    = ($StalledJobs.Count)
        RequiresAction = ($StalledJobs.Count -gt 0)
    }
}

$QueueReport

where:

  • Get-Printer gathers all locally configured print devices.
  • Get-PrintJob -PrinterObject $Printer passes the printer object directly to inspect its queue.
  • Where-Object { $_.JobStatus -match ... } filters for jobs in unhealthy states using regular expressions.
  • [PSCustomObject] aggregates device metrics into a structured report.

Execute the script from the console:

Consolepowershell
pwsh ./audit-print-spooler.ps1
Outputplaintext
PrinterName    : OneNote for Windows 10
Driver         : Microsoft Software Printer Driver
Port           : Microsoft.Office.OneNote_16001.14326.22594.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-2274977739-1597439238-4225179071-1000
Shared         : False
PendingJobs    : 0
StalledJobs    : 0
RequiresAction : False

PrinterName    : Microsoft XPS Document Writer
Driver         : Microsoft XPS Document Writer v4
Port           : PORTPROMPT:
Shared         : False
PendingJobs    : 0
StalledJobs    : 0
RequiresAction : False

PrinterName    : Microsoft Print to PDF
Driver         : Microsoft Print To PDF
Port           : PORTPROMPT:
Shared         : False
PendingJobs    : 0
StalledJobs    : 0
RequiresAction : False

PrinterName    : Fax
Driver         : Microsoft Shared Fax Driver
Port           : SHRFAX:
Shared         : False
PendingJobs    : 0
StalledJobs    : 0
RequiresAction : False
Navigation