[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5472
  • Last Modified:

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 ?
0
Senior IT System Engineer
Asked:
Senior IT System Engineer
  • 4
  • 3
2 Solutions
 
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
 
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
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now