Share via


Add-printer command not working for remote computers

Question

Friday, December 1, 2017 3:56 PM

Dear fellow admins, 

Please advise on how to fix the following error while adding a remote printer:

The specified server does not exist, or the server or printer name is invalid.  Names may not contain ',' or '\' characters.

The code I am using does not work for the remote machines when I try to send the command from the controller, however it does work if I do it locally. 

Invoke-Command -Computername $RemoteComputer -Credential $cred -ScriptBlock {net use \\servername\printername password /user:username\password;add-printer -connectionname \\servername\printername;}

All replies (7)

Tuesday, December 5, 2017 1:57 PM ✅Answered

You cannot remotely attach a remote printer.  Search for "second hop restriction".  You can only install printers directly attached to the remote system.

To attach network printers to systems use Group Policy.

\(ツ)_/


Friday, December 1, 2017 6:44 PM

What is the error?

You cannot remotely access a third machine.  Search for "second hop problem".

\(ツ)_/


Tuesday, December 5, 2017 1:25 PM

The error code is as follows:

Add-Printer : Parameter set cannot be resolved using the specified named parameters.
At line:8 char:1
+ Add-Printer -ComputerName $domainName -ConnectionName '\\CACUS\4flr_b ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Add-Printer], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Add-Printer

Tuesday, December 5, 2017 1:30 PM

There is no "ComputerName" parameter for that CmdLet when you are specifying a network connection.

Look at the help to see which parameters can be used together.

/en-us/powershell/module/printmanagement/add-printer?view=win10-ps

Always refer to the documentation to solve parameter issues.

\(ツ)_/


Tuesday, December 5, 2017 1:54 PM

Thank you for the suggestion, I have followed your advice, omitted that parameter and used this instead:

Invoke-Command -Computername $RemoteComputer -Credential $cred -ScriptBlock {
net use \\SOMESERVER\SOMEPRINTERNAME password /user:SOMESERVER\username;
add-printer -connectionname \\SOMESERVER\SOMEPRINTERNAME;}

This is what I get:

The specified server does not exist, or the server or printer name is invalid.  Names may not contain ',' or '\' characters.
    + CategoryInfo          : NotSpecified: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Add-Printer], CimException
    + FullyQualifiedErrorId : HRESULT 0x80070709,Add-Printer
    + PSComputerName        : SOMESERVER

Do you think it is a second hop problem?


Tuesday, December 5, 2017 2:05 PM

Thank you for the answer. However, the gpo won't work in a WORKGROUP environment. I thought I could push this from the WIN server to all the trusted hosts in a WORKGROUP using PS Remoting, but it turns out it's restricted. 


Tuesday, December 5, 2017 2:12 PM

It can only be done if you use CredSSP however the connection will not persist.  It will only be valid for the account setting it and that must be an admin account.

\(ツ)_/