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 ?
LVL 9
Senior IT System EngineerIT ProfessionalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lionel MMSmall Business IT ConsultantCommented:
This script should work but there are a few switches that are redundant
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"
 try this instead you had /MIR twice /z /b /zb can be replaced with /ZB only; you also had /Z twice
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"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Senior IT System EngineerIT ProfessionalAuthor Commented:
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 ?
0
Lionel MMSmall Business IT ConsultantCommented:
well I fixed the robocopy command and it should fix the security items but I don't use robocopy for this purpose but reading the explanations it should. I use takeown and icacls for security and ownership
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Senior IT System EngineerIT ProfessionalAuthor Commented:
So what's the command for the icacls ?

I'm newbie in this matter.
0
Lionel MMSmall Business IT ConsultantCommented:
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
0
Lionel MMSmall Business IT ConsultantCommented:
Glad I could help--did it fix the security issues you wanted it to?
0
Senior IT System EngineerIT ProfessionalAuthor Commented:
yes the Robocopy script that you suggested works :-)

Thanks man !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.