How to add LPR port manually?

GabeCz 1 Reputation point
2021-10-21T23:00:42.687+00:00

Hi
I'm trying to find a way to add a LPR printer port via PowerShell. The add-printerport creates standard TCP/IP port only.
Basically what this Ok button does in the background I'd like to know. Figured so far, that it creates a bunch of registry entries, which if I create via reg add, it won't show up in printmanagement.msc/ports.

142642-image.png

Thank you!

My goal is to have a script that adds a printer (say HP_MFP_Counter) on a domain joined print server (10.0.0.100) to a non-domain joined computer on the same network.

The registry entries are these, but something else is running additionally I can't figure out. This is all I found using Sysinternals Process Monitor.

Reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.0.0.100:HP_Counter_MFP" /v "Printer Name" /t REG_SZ /d "HP_Counter_MFP" /f
Reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.0.0.100:HP_Counter_MFP" /v "Server Name" /t REG_SZ /d "10.0.0.100" /f
Reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.0.0.100:HP_Counter_MFP" /v "EnableBannerPage" /t REG_DWORD /d 0 /f
Reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.0.0.100:HP_Counter_MFP" /v "HpUxCompatibility" /t REG_DWORD /d 0 /f
Reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\LPR Port\Ports\10.0.0.100:HP_Counter_MFP" /v "OldSunCompatibility" /t REG_DWORD /d 0 /f

Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
643 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 45,096 Reputation points
    2021-10-22T01:27:10.663+00:00

    Does this work (I haven't tried it)? quick-tip-create-new-lpr-printers-using-powershell


  2. Rich Matheisen 45,096 Reputation points
    2021-10-22T19:20:57.41+00:00

    It's not PowerShell, but check the C:\Windows\System32\Printing_Admin_Scripts\en-US directory for the 7 vbs scripts supplied by MS. WMI is used, so they're transferable to PowerShell, but there's a ton of definitions and options.

    The printer config script is "prncnfg.vbs".

    0 comments No comments