Remote Job - UNC or PSDrive not found

TreyS 166 Reputation points
2020-09-09T13:12:49.873+00:00

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?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,546 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. 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 $_
    }
    
    0 comments No comments

  2. 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".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.