1

So I have a Powershell script that reads a csv file that copies files from one remote directory to another.

  1. script runs

  2. script copies files from a directory on serverA to a directory on serverB.

So currently I invoke a remote command from ServerC to execute the script on serverA.

The script runs. That isn't the problem, the problem occurs with the functionality of the script, it cant copy the files due to unauthorized access error:

+ CategoryInfo          : PermissionDenied: (\\serverB\tes...file.txt:String) [Test-Path], UnauthorizedAccessException
+ FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.TestPathCommand
+ PSComputerName        : serverA

The command:

invoke-command -computer $hostname -filepath $remoteScriptPath\script.ps1 -Credential $cred -argumentlist @($var1, $var2)

If I login to the server manually and run the script it works fine (that is currently how it is used, I want to make a jenkins job that does this, hence why invoking the remote command from the jenkins server). When I invoke the script remotely, it runs, but fails the test-path on the remote server it needs to copy files over to. Not sure what the issue is, because the credentials i am using have access to all servers involved.

HAL9256
  • 12,384
  • 1
  • 34
  • 46
user2026989
  • 11
  • 1
  • 4

0 Answers0