

Quick Tip - Create New LPR Printers Using PowerShell
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.
Recommend
-
14
Quick Tip - See All The Tab-Completion Options At Once In The PowerShell Console If you’re used to working in VS Code or the PowerShell ISE, you’ve undoubtedly enjoyed intellisense which is the feature that shows you all...
-
20
Quick Tip - Split A PowerShell Collection Into Two Arrays Did you know that you can use Where-Object to split a collection into two arrays? Like, if you had an array containing the numbers 1 to 10, you c...
-
7
Quick Tip - PowerShell Supports Partial Parameter Names Did you know that PowerShell supports the usage of partial parameter names? This isn’t such a big deal since tab completion is a thing… and if you’re writing code,...
-
8
Beginner PowerShell Tip - Using Variable Properties In Strings If you’re just getting started in PowerShell, it’s possible that you haven’t bumped into this specific issue yet. Say you’ve got a variable named $user
-
15
Quick Tip - Use PowerShell To See How Many Files Are In A Directory Here’s a way to see how many files are in a directory, using PowerShell. As you likely know, you can use Get-ChildItem to get...
-
10
Quick Tip - Diagnosing Slow PowerShell Load Times I could write an entire book on “why does my PowerShell console take so long to load?” but I don’t want to write that book. Instead, here’s a way to make sure the reason...
-
11
Quick Tip - Using Variables In ActiveDirectory Filters If you work with the ActiveDirectory PowerShell module, you’ve probably used the -filter parameter to search for accounts or objects in Active Directory. Yo...
-
14
Quick Tip - Use PowerShell To Detect If A Location Is A Directory Or A Symlink In PowerShell, symbolic links (symlinks) appear pretty transparently when you’r...
-
11
Raymond Camden
-
15
A quick PowerShell tip I have a bunch of PowerShell functions that I stick in my $profile file. Simple stuff, things to make my day to day development work easier. With my sieve-like memory, I need a quick way...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK