11

Quick Tip - Create New LPR Printers Using PowerShell

 3 years ago
source link: https://thomasrayner.ca/quick-tip-create-new-lpr-printers-using-powershell/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Quick Tip - Create New LPR Printers Using PowerShell

There are a bunch of overloads for Add-Printer and Add-PrinterPort to accommodate different kinds of printers and ports. I found it tough, however, to find real examples of how to use these cmdlets to add LPR printers and ports. Not TCP/IP, not TCPLPR, not local ports. I figured it out, though, and now here’s how I did it.

foreach ($printer in $(Get-Content -Path 'c:\temp\printers.txt')
{
    Add-PrinterPort -ComputerName PrintServer -PrinterName $printer -HostName 'PrinterHostName'
    Add-Printer -ComputerName PrintServer -DriverName 'Name Of Your Driver' -PortName "PrinterHostName:$printer" -Name $printer
}

There are no real surprises here. It’s just a matter of finding the right combinations of parameters and their values to make LPR printers and ports happen. In this example, I’m creating a bunch of them out of a list I have in a file.

Written on October 28, 2015

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK