Search code examples
powershellrobocopy

Robocopy Access Denied Error 5 From Powershell


I am copying files from my build server to a web server on Windows Server 2016. I am running the following from PowerShell. I am running this script with an administer account which has read/write access to the destination directory.

robocopy $Path\Items $_\Items /Sec /copy:DT /MIR /NDL /NS /NP /MT /w:1 /r:1 /R:20 2>&1 | out-host

I get the following error

ERROR 5 (0x00000005) Creating Destination Directory \SOMEPATH\Data\Items\ Access is denied.


Solution

    • Ensure that you open your powershell session as an administrator (runas)
    • Also check the NTFS permission on the destination path and not only the security permissions.
    • If you are using a DFS path you should be better with the UNC path of the actual servername.