How to install a shared printer with powershell instead of the windows utility

Welcome Forums General PowerShell Q&A How to install a shared printer with powershell instead of the windows utility

Viewing 0 reply threads
  • Author
    Posts
    • #205242
      Participant
      Topics: 1
      Replies: 0
      Points: -9
      Rank: Member

      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 at http://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

      1. From the Printers & scanners wizard, I click on Add a printer & scannerClick for an image
      2. 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
      3. The Add Printer Wizard appears and I choose Select a shared printer by name, then click NextClick for an image
      4. 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.
      5. 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 and PortName Parameters to the Add-Printer command but I get the error message: Parameter set cannot be resolved using the specified named parameters.

      So there it is. Any help will be greatly appreciated. I hope my first question on the site is up to standard!

Viewing 0 reply threads
  • The topic ‘How to install a shared printer with powershell instead of the windows utility’ is closed to new replies.