Open nicolas6969 opened 6 years ago
It seems that currently the resource expects that the destination folder is fully synchronized and does not have extra folders and files. Doesn't look like there are parameters to handle your case.
I think there need to be new boolean parameters to control what error codes are accepted and should return $true or $false. Like AllowExtraFoldersInDestination
, AllowExtraFilesInDestination
, if that is a possibility.
Thanks a lot for the feedback.
Maybe the resource should be updated to not return $false, if the errorcode is not greater than 8. Microsoft says on https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
So that means every error code less or equal 8 is not an error?!
If there are errors during copy operation then the Set-TargetResource should throw an error. The Test-TargetResource does not do any actual copy operation but validates what the state would be if it would do a copy operation. Not sure it should return $false if that returns that it could not copy at all, then I think Test-TargetResource
should throw also.
Some user might want it to return false if there are added files in the destination, because there should be no extra files or folders in the destination so they want to purge those. So the resource need to have a way to support several scenarios, that is does not have today.
The user intent could be deduced from arguments passed to robocopy. Specifically, /MIR
or /PURGE
instruct robocopy to remove extra files, so the resource could treat exit code 2 as compliant if those arguments are not present.
We are using the xRobocopy module to copy various files/folders from different sources to one same destination. As the destination is never in sync with the different sources, the returned errorcode is always 3 (when at least one file has been copied) or 2 (when no files have been copied), because there are always extra files detected).
We have tried using /XX, but it doesn't affect the returned errorcode. Unfortunately, the resource gives back $false, as soon as the returned errorcode is not 0. So as long as extra file/folders are detected in destination, Test-DscConfiguration returns the related resources as not in desired state.
From our perspective, the extra files/folders (errorcodes 2 and 3) should result in "in desired state", so the resource test should return $true. Is there a way to accomplish this?
Or is this maybe an issue related to robocopy.exe, as the flag /XX should return errorcode 0 although extra folders/files are detected?