Remote Powershell Session - Accessing network share

Nathaniel Miller 21 Reputation points
2023-05-19T21:58:35.7733333+00:00

Scenario: I have 3 computers: Comp1, Comp2, Comp3.

Comp3 has a network share, with a file in it.

I'm trying to write a PowerShell script that will run on Comp1; it will run a Remote PowerShell session on Comp2, which will copy the file from Comp3's share and carry out further commands using the file.

When I run the script, it keeps telling me Access Denied when it tries to access the network share. If I take the contents of the remote script and run it locally on Comp2, it works perfectly.

I've confirmed with "whoami" that it is running under the same account on Comp1 remoting into Comp2, and Comp2 locally (currently using domain admin, for testing purposes).

I even tried taking the PowerShell script and running it on the system using PSExec to launch the PowerShell session on Comp2, with the same result.

Any suggestions appreciated.

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,455 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,831 Reputation points
    2023-05-20T02:05:28.3466667+00:00

    Congratulations! You too have discovered the Second Hop Problem.

    A succinct explanation is that you can't reuse the credential you used to connect to Comp2 to connect to Comp3.

    See here for an explanation and possible solutions: https://learn.microsoft.com/en-us/powershell/scripting/learn/remoting/ps-remoting-second-hop?view=powershell-5.1