I believe that this is referred to as the "double hop problem".
Remote Job - UNC or PSDrive not found
I have a scripts installed locally on a group of servers. Lets call them the worker scripts. I want to execute those scripts, remotely, as background jobs, from a management workstation. Lets call this the management script.
I have the management script/remote job process working. My problem is when the worker scripts run on the remote machines, as jobs, they fail to "see" a file share where the worker scripts should copy some files.
The management script uses a credential to launch the remote worker scripts and that credential/account has access to the target share where the files should copy. CredSSP is enabled.
In the worker script, I first referenced the destination file share via UNC. Then I created a PSDrive to reach it. Either method works if the worker script is executed locally/interactively on the remote servers.
I'm missing something in the security model, but what?
2 additional answers
Sort by: Most helpful
-
Rich Matheisen 46,801 Reputation points
2020-09-09T17:37:16.873+00:00 When you collect the output of the job is there any indication of what the problem was?
I think I'd start by wrapping the New-PSDrive in a Try/Catch, something like this:
Try{ New-PSDrive . . . -ErrorAction STOP } Catch{ $_ Throw $_ }
-
TreyS 166 Reputation points
2020-09-10T14:52:36.747+00:00 Thanks to MotoX80.
And here is another link with a walk-through by the Scripting Guy, Ed Wilson.
There is a bunch of stuff out there on "the second hop problem".