Share via


ERROR 5 (0x00000005) Accessing Source Directory when using PowerShell/ROBOCOPY and invoke-command

Question

Tuesday, July 12, 2011 3:31 AM

Hello I have a very simple script (backup.ps1) that runs fine "locally" on destinationServer.

$DTS = (get-date).ToString("yyyyMMdd.HHmm")

ROBOCOPY \sourceServer\Data \destinationServer\Databackup\DTS /MIR /V /TS /NP /LOG:\ destinationServer\Databackup\logs\DTS.log

When I try to run this same script using invoke-command from the sourceServer it fails with error below

invoke-command -computername destinationServer -filepath "D:\PSScripts\backup.ps1"

   ROBOCOPY     ::     Robust File Copy for Windows                             

  Started : Mon Jul 11 22:48:42 2011

2011/07/11 22:48:42 ERROR 5 (0x00000005) Getting File System Type of Source [\sourceServer\Data\](file://\sourceServer\Data)

Access is denied.

   Source - [\sourceServer\Data\](file://\sourceServer\Data)

     Dest : [\destinationServer\Databackup\20110711.2248\](file://\destinationServer\Databackup\20110711.2248) 

    Files : *.*

 

  Options : *.* /V /TS /S /E /COPY:DAT /PURGE /MIR /NP /R:1000000 /W:30

2011/07/11 22:48:42 ERROR 5 (0x00000005) Accessing Source Directory \ sourceServer \Data\

Access is denied.

 I am running the scripts with the same domain administrator in both cases.  Somehow something is getting lost when running the invoke-command and how it interacts with shares.  The  basic Shares and Security has been checked and recheck.  I am pretty sure permissions are setup as needed as I am able to run the command locally and also manually move the file.  I am open for a better method for  achieve this?.  One other thing that may help is that the script runs fine (remotely using invoke-command if I change the source agruement in the Robocopy to a local path

Ie

ROBOCOPY D:\Temp\dummyData \destinationServer\Databackup\DTS /MIR /V /TS /NP /LOG:\ destinationServer \Databackup\logs\DTS.log

All replies (2)

Tuesday, July 12, 2011 11:24 AM âś…Answered | 1 vote

multi-hop problem.... you cant go from Server A to B and then from B to C without CredSSP

http://msdn.microsoft.com/en-us/library/ee309365(v=vs.85).aspx

http://www.ravichaganti.com/blog/?p=1230

Justin Rich
http://jrich523.wordpress.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Wednesday, April 3, 2013 10:50 AM

yes.. enabling WSManCredssp for both the machines solves teh problem.

thanks brother.