[英]robocopy using secfix to fix permissions of ONLY subdirectories, excluding root directory
I have a rather interesting issue that I think is logically possible via Robocopy, but I cannot find the correct syntax to accomplish this goal.我有一个相当有趣的问题,我认为通过 Robocopy 在逻辑上是可能的,但我找不到正确的语法来实现这个目标。
Problem :问题:
I am trying to sync a lot of data via two remote shares.我正在尝试通过两个远程共享同步大量数据。 IE: robocopy "\share1\root" "\share2\root" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64
IE: robocopy "\share1\root" "\share2\root" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64
The issue arises due to the fact that the root directory has different permissions than all of the subdirectories.出现此问题的原因是根目录与所有子目录具有不同的权限。 I have close to 1000 subdirectories that makes this tedious and difficult to manually do.
我有将近 1000 个子目录,这使得手动操作变得乏味且困难。
Current Issue目前的问题
Running 'robocopy "\share1\root" "\share2\root" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64' changes ONLY the permissions of the root directory, but not the subdirectories.运行 'robocopy "\share1\root" "\share2\root" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64' 仅更改根目录的权限,但不更改根目录的权限子目录。
Running 'robocopy "\share1\root\subdirectory1" "\share2\root\subdirectory1" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64' DOES result in the desired state, but is far too tedious to do for over 1000 sub directories运行 'robocopy "\share1\root\subdirectory1" "\share2\root\subdirectory1" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64' 确实会产生所需的 state,但是对于超过 1000 个子目录来说太繁琐了
Desired Results期望的结果
Either a robocopy command that would ONLY change the permissions on the subdirectories (and the child elements within those directories) but maintain the perms on the root directory, or another means of accomplishing the above.要么是一个 robocopy 命令,它只会更改子目录(以及这些目录中的子元素)的权限,但会保留根目录上的权限,或者是另一种实现上述目的的方法。
Any help would be appreciated!任何帮助,将不胜感激!
I guess you can technically use PowerShell to automate looping through your directory tree.我猜你可以在技术上使用 PowerShell 来自动循环遍历你的目录树。
Get-ChildItem -Path '\share1\root' -Directory | Foreach-Object {
robocopy "\share1\root\$($_.Name)" "\share2\root\$($_.Name)" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.