Add-printer remotely

Welcome Forums General PowerShell Q&A Add-printer remotely

Viewing 9 reply threads
  • Author
    Posts
    • #28030
      Participant
      Topics: 3
      Replies: 4
      Points: 0
      Rank: Member

      I am trying to run this command remotely through invoke-command and pssessions, but it does not work. Locally I am able to add-printer and remove-printer, but the exact same commands don't work remotely. I get an error that the printer server or name may be incorrect. Any ideas?

    • #28031
      Keymaster
      Topics: 13
      Replies: 4872
      Points: 1,844
      Helping HandTeam Member
      Rank: Community Hero

      Two possibilities.

      One, when you remote into a machine, you don't spin up a full user profile. It's more like connecting to a network share. So it could be running into a problem if it's expecting a user profile.

      Second, when your credentials are delegated to the remote machine, it can only use them for local resources. If it needs to connect to a print server, then it's likely failing if the print server won't accept an anonymous connection. This is called the "second hop" problem, and it's discussed at some length in "Secrets of PowerShell Remoting" (free from the Resources/eBooks menu here), along with workarounds.

    • #28032
      Participant
      Topics: 0
      Replies: 15
      Points: 22
      Rank: Member

      Depending on the version of PowerShell, I have had success with

          #Add Ports
          Add-PrinterPort -Name $PrinterPort -PrinterHostAddress $PrinterIP -ComputerName $Computer   
      # Add Printers
          Add-Printer -computername $Computer -name $PrinterName -PortName $PrinterName-DriverName "HP Universal Printing PCL 6"
       

      That assumes the driver is on the client PC already.

      Also note this is NOT run thru a PSSession or Invoke-Command. The Add-Printer and Add-Printerport have a -computername parameter.

    • #28034
      Participant
      Topics: 3
      Replies: 4
      Points: 0
      Rank: Member

      That worked!

    • #28036
      Participant
      Topics: 3
      Replies: 4
      Points: 0
      Rank: Member

      Greg,

      These commands work I am able to remotely add and remove printers. If I want to use this to add printers to multiple computer at once the variable doesn't work. Example $computer = user1,user2. This gives me a failure.

    • #28037
      Keymaster
      Topics: 13
      Replies: 4872
      Points: 1,844
      Helping HandTeam Member
      Rank: Community Hero

      The -ComputerName parameter of Add-Printer only accepts a single computer name.

      As in the help file:

      -ComputerName String

      Not:

      -ComputerName String[]

    • #28039
      Participant
      Topics: 3
      Replies: 4
      Points: 0
      Rank: Member

      Thank you Don.

    • #28044
      Participant
      Topics: 0
      Replies: 15
      Points: 22
      Rank: Member

      yep, the quick and easy way is :

      $Computers = 'PC1','PC2','PC3'
      ForEach ($Computer in $Computers) {
              #Add Ports
             Add-PrinterPort -Name $PrinterPort -PrinterHostAddress $PrinterIP -ComputerName $Computer   
             # Add Printers
             Add-Printer -computername $Computer -name $PrinterName -PortName $PrinterName-DriverName "HP Universal Printing PCL 6"
      }
       
    • #79363
      Participant
      Topics: 0
      Replies: 1
      Points: 0
      Rank: Member

      Is there a way to reference a specific share with printer drivers located in it for the printer rather than using the ones from the machine?

      • #79456
        Participant
        Topics: 4
        Replies: 11
        Points: 34
        Rank: Member

        I believe you'd then be looking at Add-PrinterDriver, you can provide a path to an INF file. Unfortunately, the help for Add-PrinterDriver is somewhat lacking. You need to install the print(er) driver, before you can add a printer that uses that driver.

        JBLewis

    • #103817
      Participant
      Topics: 0
      Replies: 1
      Points: 0
      Rank: Member

      Printer server is working with a client and it is work is very fast but sometimes It shows error as printer server name is incorrect. It usually shows when a server is down. A solution to this problem is that printer driver is reinstalling with the correct name. Ricoh printer support provides you printer server repair service

Viewing 9 reply threads
  • The topic ‘Add-printer remotely’ is closed to new replies.