Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

How to fix directory and file ownership using Robocopy script on Windows Server 2012 R2 ?

Hi People,

Can anyone here please share me the Robocopy scipt to fix the file ownership and the directory ownership so that the owner from the source file server (Server 2008) will be the same as the target or the new file server ?

here's what I use to perform the files initially from the target server (2012 R2):
robocopy.exe "\\OldFileServer\homedirectories" F:\Users *.* /e /xo /XA:O /zb /copyall /dcopy:DAT /secfix /sec /r:0 /w:0 /np /nfl /ndl /tee /log:"C:\Temp\robocopyUsers.log"

With the script above, the directory owner and the file owner is the NewServer2012R2\Administrators (the local admin) instead of the individual users like what it says on the source file server.

one of the experts here suggest me to use this script below:
robocopy.exe "\\OldFileServer\homedirectories" F:\Users *.* /MIR /E /Z /SECFIX /SEC /XO /XJ /Z /B /ZB /COPY:DATSO /MIR /DCOPY:T /R:0 /W:0 /NP /NFL /NDL /TEE /LOG:"C:\Temp\robocopyUsers.log"

But I with the script above, the data is all overwritten again from the beginning thus making it very long to complete.

Can anyone please help me ?
ASKER CERTIFIED SOLUTION
Avatar of Lionel MM
Lionel MM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Albert Widjaja

ASKER

thanks Lionel,

so in this case by running the script that you suggested below
robocopy.exe "\\OldFileServer\homedirectories" F:\Users *.* /E /SECFIX /SEC /XO /XJ /ZB /COPYALL /MIR /DCOPY:T /R:0 /W:0 /NP /NFL /NDL /TEE /LOG:"C:\Temp\robocopyUsers.log"

it should fix the ACL and files & directory ownership without copying all data/files from the source file server ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So what's the command for the icacls ?

I'm newbie in this matter.
Well if other experts are recommending robocopy I'd give it a try--I am going to try it myself because takeown and icacls can be challenging to get right. Run the command I fixed and see if it results in what you wanted--this of course assumes that F:\Users has the right ownership and permissions
Glad I could help--did it fix the security issues you wanted it to?
yes the Robocopy script that you suggested works :-)

Thanks man !