Command works locally, but not remote

I’m trying to add a printer to a computer with this PS

Add-Printer -ConnectionName \\kc-util-vm\kc-ar-xerox

When I run this locally on my test computer, it adds the printer as expected.

When I run it remotely, from my utility server:

invoke-command -computername $hostname -script {Add-Printer -ConnectionName \\kc-util-vm\kc-ar-xerox}

I get this error:

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 : kc-gentest-lt1

I also tried it using PSSession:

 enter-pssession $hostname
[kc-gentest-lt1]: PS C:\Users\kpkb-adm\Documents> Add-Printer -ConnectionName \\kc-util-vm\kc-ar-xerox

I get this:

Add-Printer : 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

Can someone explain the difference between running this locally on kc-gentest-lt1 and running it on the same computer, but from a remote machine? What am I missing?

To reiterate, the “add-printer…” command works when I run it directly on the target computer.

Thanks!

—K

Could it be the double-hop problem? This article explains what that is

2 Likes

It absolutely, one hundred percent, is the double hop problem.

Thanks for the info! I read through the article and understand what’s happening. Solution is a bit complicated for this moment, so I am just running the command locally in a remote session - just a handful of users need this right now.
Once fires are out, I will revisit and write it into an actual script that will be useful

I appreciate your help!

—K

If you have a way to get a valid credential in a secure way (like with PowerShell SecretsManagement) on the server that’s running the invoke-command, I’d suggest taking a look at the last option in that doc. It’s a relatively easy option once you have access to the credential

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.