The problem
I'm trying to install a shared printer on windows 10 64 bit machine using Powershell. The printer originates from an Ubuntu's CUPS (Common Unix Printing Service) and reachable athttp://host:port/printers/printername
.
Right now this process is done manually with the Printers & scanners wizard and I’d like to automate it with Powershell.
Here is what the manual process looks like
- From the Printers & scanners wizard, I click on
Add a printer & scanner
. Click for an image - I then always click on
The printer that I want isn't listed
, just to be able to enter the link and be sure it's the right printer. Click for an image - The
Add Printer
Wizard appears and I chooseSelect a shared printer by name
, then clickNext
. Click for an image - Here, although the driver should have already been installed prior to this process, the popup to install the printer driver is really useful and would be great if that popup could come up using Powershell if the driver isn't installed.
- I get a success message, Next and done.
What I've tried
I tried installing the printer with the following sequences of commands with the driver already installed:- Add-Printer Only, results in an error message (ip, port and printername changed manually)
PS C:\> Add-Printer -ConnectionName "http://ip:port/printers/printername"
Click here to see output. I couldn't copy-paste it here because "it looks like spam"
- Add-PrinterPort then Add-Printer, commands pass and I see the printer, but spits and error when I try to print a test page ("Error printing on myprinter").
PS C:\> Add-PrinterPort -Name "myport" -PrinterHostAddress "xx.xx.xxx.xxx" -PortNumber xxx
PS C:\> Add-Printer -Name "myprinter" -DriverName "Brother MFC-L2720DW series" -PortName "myport"
- I also tried using the both
ConnectionName
andPortName
Parameters to the Add-Printer command but I get the error message:Parameter set cannot be resolved using the specified named parameters.