Goal: add a network printer via Remote Desktop’s command-line to numerous Macs.
The following commands have worked for me:
lpadmin -p "NAME" -v "URL" -P "PPD" -o printer-is-shared=false -E cupsenable "NAME" cupsaccept "NAME"
- -E — enables the printer.
- -o printer-is-shared=false — the added printers are shared by default (i.e. “Share this printer on the network” would be ticked). Since my printer is already shared on the network, I don’t want to share it again from the Macs.
- NAME — arbitrary name, can be anything, e.g. “MyBadassPrinter”.
- URL — the printer’s URL.
- PPD — the path to a .ppd (PostScript Printer Description) file.
Probably you don’t know how to find the URL and the PPD of the printer.
The first step to retrieve them is to add the printer to your computer via System Preferences > Print & Scan.
Now let’s find the URL. What follows is probably not the best way to do it, but it’s worked for me. Run the following to enable CUPS web-interface:
In your web-browser open http://localhost:631/printers/, click on your printer’s name and copy the URL after “Connection”:
How to get the PPD? This is easier: go to /etc/cups/ppd/ and copy the PPD file. Obviously you’d want to put it on a local NAS or in some other place that would be accessible by other Macs.
The final command for me was:
lpadmin -p "AFFA-ST-MFP-1" -v "dnssd://AFFA-ST-MFP-1._ipp._tcp.local." -P "/Volumes/Servers/AFFA_ST_MFP_1.ppd" -o printer-is-shared=false; cupsenable "AFFA-ST-MFP-1" -E; cupsaccept "AFFA-ST-MFP-1";