Add-printer remotely

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?

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.

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.

That worked!

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.

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

As in the help file:

-ComputerName String

Not:

-ComputerName String

Thank you Don.

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"
}
 

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?

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

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