How To

PowerShell Get Printers: Bulk Add TCP/IP Network Printers

Transform tedious manual printer installation into efficient automated workflows for enterprise environments

By InventiveHQ Team

This comprehensive guide demonstrates how to efficiently add single printers and process multiple printers in bulk using CSV files, dramatically reducing manual effort and potential errors. In PowerShell, bulk printer deployment is a two-cmdlet job: Add-PrinterPort creates a Standard TCP/IP port (RAW protocol, TCP port 9100 by default) for each printer's IP, and Add-Printer binds an installed driver to that port — wrap both in a foreach loop over an imported CSV and you can stand up dozens of network printers in one elevated PowerShell session.

That is the summary an AI Overview will give you. What it can't show you is the order the cmdlets must run in, the driver-store gotcha that breaks most first attempts, and a re-runnable script that doesn't die on the first bad row. The diagram, comparison table, and symptom-to-fix table below cover those.

The Bulk Deployment Pipeline at a Glance

Every reliable bulk-printer script follows the same four stages. Ports must exist before printers, and drivers must be staged before either — get the order wrong and Add-Printer fails.

PowerShell bulk printer deployment pipeline A CSV feeds a foreach loop that first creates a TCP port with Add-PrinterPort, then installs the printer with Add-Printer against a staged driver. CSV in, network printers out — one loop per row printers.csv PrinterName IPAddress DriverName foreach ($printer in $printerList) 1. Add-PrinterPort creates TCP port RAW / port 9100 ip_10.0.0.7 2. Add-Printer binds driver to the port Office Printer Driver store Get-PrinterDriver must be staged FIRST Order matters: stage drivers, create the port, then add the printer — never reverse it.

Creating TCP Printer Ports with PowerShell

The foundation of network printer management starts with creating TCP/IP printer ports. PowerShell's Add-PrinterPort cmdlet provides a straightforward method for establishing these connections programmatically.

Basic Syntax and Parameters

The fundamental command structure for creating TCP printer ports follows this pattern:

`Add-PrinterPort -Name "ip_IPAddress" -PrinterHostAddress IPAddress`

Practical Example

Here's a concrete example creating a TCP port for a printer with IP address 10.0.0.7:

`Add-PrinterPort -Name "ip_10.0.0.7" -PrinterHostAddress 10.0.0.7`

💡 Pro Tip: The naming convention "ip_" followed by the IP address creates easily identifiable port names that clearly indicate their purpose and target device.

RAW vs LPR: Which Protocol Should the Port Use?

Add-PrinterPort defaults to a RAW port, but Standard TCP/IP ports support two protocols. Most modern network printers and print servers use RAW; LPR survives mainly for legacy Unix/mainframe queues and certain appliances.

RAW (default)LPR
TCP port9100515
Spec / originHP JetDirect de-facto standardRFC 1179
PowerShell flagsnone needed-LprQueueName "<queue>" -LprByteCounting
OverheadLower — raw byte streamHigher — queue name + byte counting
When to useAny modern printer, MFP, or print serverLegacy queues, old Unix/AS400 hosts, or appliances that only speak LPR
# LPR variant — only when the device requires it
Add-PrinterPort -Name "lpr_10.0.0.7" -PrinterHostAddress 10.0.0.7 `
    -LprQueueName "PORT1" -LprByteCounting

If you are unsure, use RAW. Almost every printer sold in the last two decades listens on 9100.

Bulk TCP Port Creation Using CSV Files

For environments with multiple printers, processing CSV files provides significant efficiency gains. This approach allows you to prepare printer information in advance and execute batch operations with minimal manual intervention.

PowerShell Script for CSV Processing

# Import the CSV file containing printer IP addresses
$printerportlist = Import-Csv C:\printerportlist.csv

# Loop through each row in the CSV file
Foreach ($port in $printerportlist) {
    # Create standardized port name using IP address
    $name = "ip_" + $port.ip

    # Create the TCP printer port
    Add-PrinterPort -Name $name -PrinterHostAddress $port.ip

    # Output confirmation for each port created
    Write-Host "Created TCP port: $name for IP: $($port.ip)" -ForegroundColor Green
}
Advertisement

Required CSV File Structure

Your CSV file must include an "ip" column header. Here's an example structure:

ip
10.0.0.7
10.0.0.8
10.0.0.9

Installing Printers with PowerShell

Once TCP ports are established, the Add-Printer cmdlet connects printers to these ports using appropriate drivers. This process requires careful attention to driver availability and naming conventions.

⚠️ Important: Verify printer drivers are installed before running Add-Printer commands. Use Get-PrinterDriver to list available drivers on your system.

Basic Add-Printer Syntax

`Add-Printer -Name "PrinterName" -DriverName "Printer Driver Name" -PortName "PortName"`

Parameter Definitions

  • -Name: Display name for the printer (e.g., "Office Printer")

  • -DriverName: Exact driver name from Get-PrinterDriver output

  • -PortName: TCP port name created earlier (e.g., "ip_10.0.0.7")

Practical Example

# Add printer using previously created TCP port
Add-Printer -Name "Office Printer" -DriverName "HP Universal Printing PCL 6" -PortName "ip_10.0.0.7"

Complete Bulk Printer Installation Solution

This comprehensive script combines TCP port creation and printer installation into a single automated process. It reads from an enhanced CSV file containing all necessary printer information and handles both operations sequentially.

Enhanced CSV File Structure

Create a comprehensive CSV file (save as printers.csv) with the following structure:

PrinterName,IPAddress,DriverName
OfficePrinter1,10.0.0.7,HP Universal Printing PCL 6
OfficePrinter2,10.0.0.8,Canon Generic Printer
OfficePrinter3,10.0.0.9,Brother HL-2270DW Series

Complete Automation Script

# Import printer configuration from CSV file
$printerList = Import-Csv -Path "C:\printers.csv"

# Process each printer in the configuration file
foreach ($printer in $printerList) {
    # Generate standardized port name based on IP address
    $portName = "ip_" + $printer.IPAddress

    try {
        # Create TCP/IP port for the printer
        Write-Host "Creating TCP Port for $($printer.PrinterName) at $($printer.IPAddress)" -ForegroundColor Cyan
        Add-PrinterPort -Name $portName -PrinterHostAddress $printer.IPAddress

        # Install printer and associate with port and driver
        Write-Host "Installing printer: $($printer.PrinterName)" -ForegroundColor Yellow
        Add-Printer -Name $printer.PrinterName -DriverName $printer.DriverName -PortName $portName

        Write-Host "✓ Successfully configured: $($printer.PrinterName)" -ForegroundColor Green
    }
    catch {
        Write-Host "✗ Error configuring $($printer.PrinterName): $($_.Exception.Message)" -ForegroundColor Red
    }
}

Write-Host "`nBulk printer installation completed!" -ForegroundColor Green

💡 Best Practice: Run PowerShell as Administrator to ensure proper permissions for printer installation. Test the script with a small subset of printers before processing large batches.

Making the Script Re-Runnable (Idempotent)

The script above throws a terminating error if a port or printer already exists, which means you cannot safely re-run it after a partial failure. Guard each create with an existence check so the script becomes idempotent — run it a hundred times and it converges to the same state:

foreach ($printer in $printerList) {
    $portName = "ip_" + $printer.IPAddress
    try {
        # Only create the port if it does not already exist
        if (-not (Get-PrinterPort -Name $portName -ErrorAction SilentlyContinue)) {
            Add-PrinterPort -Name $portName -PrinterHostAddress $printer.IPAddress
        }
        # Only add the printer if it is not already installed
        if (-not (Get-Printer -Name $printer.PrinterName -ErrorAction SilentlyContinue)) {
            Add-Printer -Name $printer.PrinterName -DriverName $printer.DriverName -PortName $portName
        }
        Write-Host "✓ Ensured: $($printer.PrinterName)" -ForegroundColor Green
    }
    catch {
        Write-Host "✗ $($printer.PrinterName): $($_.Exception.Message)" -ForegroundColor Red
    }
}

This is the version to deploy in production — GPO startup scripts, Intune remediation, or MDT task sequences all re-run, and a non-idempotent script will spam errors the second time through.

Expected Output

When executed successfully, the script provides clear feedback for each operation:

Creating TCP Port for OfficePrinter1 at 10.0.0.7
Installing printer: OfficePrinter1
✓ Successfully configured: OfficePrinter1

Creating TCP Port for OfficePrinter2 at 10.0.0.8
Installing printer: OfficePrinter2
✓ Successfully configured: OfficePrinter2

Bulk printer installation completed!

Troubleshooting and Best Practices

Symptom → Cause → Fix

SymptomRoot causeFix
The specified driver does not existDriver name in CSV doesn't match the driver store exactlyRun Get-PrinterDriver | Select Name and copy the name verbatim; stage missing drivers with Add-PrinterDriver
Access is denied / permission errorPowerShell session isn't elevatedRelaunch PowerShell "Run as Administrator"
The specified port already exists on re-runNon-idempotent script re-creating an existing portGuard with Get-PrinterPort -ErrorAction SilentlyContinue (see idempotent script above)
Printer installs but nothing printsWrong protocol/port — device expects LPR, not RAW 9100Recreate the port with -LprQueueName / -LprByteCounting (see RAW vs LPR table)
Port creation hangs or times outPrinter IP unreachable or blocked by firewall/VLANTest-NetConnection <ip> -Port 9100 to confirm the RAW port is open
Import-Csv returns nothing or wrong columnsHeader names don't match $printer.IPAddress etc.Match column headers to the properties your loop references (case-insensitive, but names must exist)
Script stops on the first bad printerNo error handling around the loop bodyWrap each iteration in try/catch so one failure doesn't abort the batch

Verification Commands

Use these commands to verify successful installation:

# List all printer ports
Get-PrinterPort

# List all installed printers
Get-Printer

# List available printer drivers
Get-PrinterDriver

Summary

PowerShell transforms printer management from a tedious manual process into an efficient automated workflow. By leveraging the Add-PrinterPort and Add-Printer cmdlets with CSV file processing, system administrators can deploy multiple network printers quickly and consistently.

This approach not only saves significant time when managing large printer deployments but also reduces configuration errors through standardized automation. Whether configuring a single printer or managing enterprise-scale print infrastructure, these PowerShell techniques provide the foundation for professional, scalable printer management.

For organizations seeking comprehensive IT automation and cybersecurity guidance, InventiveHQ's managed services provide expert support for streamlining infrastructure management while maintaining robust security protocols.

Frequently Asked Questions

How do I add a TCP/IP printer port in PowerShell?

Use Add-PrinterPort with a name and the printer's IP: Add-PrinterPort -Name "ip_10.0.0.7" -PrinterHostAddress 10.0.0.7. This creates a Standard TCP/IP port that defaults to the RAW protocol on TCP port 9100. Run the command in an elevated (Administrator) PowerShell session, then confirm it exists with Get-PrinterPort.

What port does a Standard TCP/IP printer port use by default?

A Standard TCP/IP port created by Add-PrinterPort uses the RAW protocol on TCP port 9100 (the HP JetDirect de-facto standard) unless you override it. To use LPR instead, add -LprQueueName "<queue>" -LprByteCounting, which switches the port to the LPR protocol on TCP port 515 as defined in RFC 1179.

How do I bulk install printers from a CSV file with PowerShell?

Build a CSV with PrinterName, IPAddress, and DriverName columns, import it with Import-Csv, then loop each row with foreach, calling Add-PrinterPort to create the port and Add-Printer to attach the driver. Wrap each iteration in a try/catch so one bad printer does not halt the batch.

Why does Add-Printer fail with "The specified driver does not exist"?

Add-Printer only accepts a driver name that is already staged in the Windows driver store on that machine. Run Get-PrinterDriver to see the exact installed names, and stage missing drivers first with Add-PrinterDriver. The DriverName in your CSV must match the store name character-for-character, including spaces and version suffixes.

How do I create an LPR printer port instead of RAW in PowerShell?

Add-PrinterPort supports LPR with the -LprQueueName and -LprByteCounting parameters, for example Add-PrinterPort -Name "lpr_10.0.0.7" -PrinterHostAddress 10.0.0.7 -LprQueueName "PORT1" -LprByteCounting. LPR uses TCP port 515; RAW (the default) uses TCP port 9100.

Do I need administrator rights to add printers with PowerShell?

Yes. Add-PrinterPort and Add-Printer write to machine-level configuration and the driver store, so the PowerShell session must be elevated (Run as Administrator). Without elevation you will hit Access Denied or permission errors even though the cmdlets appear to run.

How can I check whether a printer port already exists before creating it?

Use Get-PrinterPort -Name $portName -ErrorAction SilentlyContinue and test the result before calling Add-PrinterPort. Re-running Add-PrinterPort on an existing name throws a terminating error, so guarding with an existence check makes the script idempotent and safe to re-run.

How do I remove printers and ports created by PowerShell?

Remove the printer first with Remove-Printer -Name "Office Printer", then delete the port with Remove-PrinterPort -Name "ip_10.0.0.7". A port cannot be removed while a printer still references it, so always remove the printer before its port.

Can I deploy these printers to all users on a machine?

Printers created with Add-Printer are per-machine connections, so any user who logs on to that computer sees them. For per-user network printer deployment across many machines, use Group Policy Preferences or a logon script instead, since those target the user context rather than the local spooler.