Robocopy not working

Hi Team,

I am using Robocopy command to copy some files/directory from a pullserver to target node in DSC. When I run the same command in powershell it works fine, but when I am using the same in Script resource , it gives me Access Denied error.(I tried using xRobocopy module, but got the same error).

All other DSC scripts running fine with the same credential(Even some file resource written to copy some file also work fine).Here is the robocopy command

ROBOCOPY.exe “\$PullServer\d`$\xxxxxxx” “D:\xxxxx” /DCOPY:T /MIR /v /log:D:\logcopy.txt

Any suggestion would be much appreciated.


Do you have WMF v4 or v5 Production Preview installed on your DSC node?

If you are using WMF v5 Production Preview you will need to set PSDSCRunAsCredential of your Script resource.

configuration Example

    Script Test
        GetScript = {}
        SetScript = {}
        TestScript = {}
        PsDscRunAsCredential = $AdminCredential

Similar to examples on below pages:

Hi Daniel,

Currently I am on WMF v4 and I am already using Admin account to run this script, but it throws a Access Denied error 5.

The real problem is the same command works fine powershell window opened in the same Admin credential, but it does not work in DSC

Here is the DSC script repository:

Script copyRepository

        GetScript = {
            #Do Nothing

        SetScript ={
           C:\Windows\System32\Robocopy.exe "\\xxxxxxx\xxxServerxxxx" "D:\xxxx" /DCOPY:T /MIR /v /log:D:\logcopy.txt
        TestScript = {
         Credential = $cred

In event viewer Robocopy doesn’t throw any error, it simply gets executed correctly only the error comes in log.
So, What might be the issue with Robocopy not working in DSC for a credential , but works fine in powershell with same credential?


The LCM runs your configurations as System, not as Admin. So when you’re testing in the console, that’s not the same account that the LCM would use.

Hi Don,

I checked with the process monitor for both the powershell and DSC in the server. The process for Robocopy is run by the same Admin credential provided.

While opening the powershell window, I am opening it explicitly with the Admin credential and for DSC execution I am providing Credential parameter in Script resource.


Hi Aravinda,

My experience with robocopy is that it doesn’t play well with drive letters as source or destination in scripts. Try using UNC paths:

ROBOCOPY \\Server1\reports \\Server2\backup

Hi Tony,

I tried this UNC path also, but looks like it throws the same Access Denied error for this when run using ScriptResource, but if I run the same from powershell console it works fine.

I also tried giving full permission to a credential for both folders, but nothing clicked.

Did anybody face the same issue with Robocopy and please let me know if the robocopy is working for anybody in DSC.