权限Powershell脚本的继承

Inheritance of Permissions Powershell Script

我正在尝试创建一个脚本来传递子文件夹的继承权。

例如:

C:/template has x y z permissions
C:/template/test only has x permissions

我希望 C:/template 中的所有子文件夹和文件都获得 x y z 权限。

类似于 Robert Prust 制作的 script here 的东西(它不执行):

$ACL = Get-Acl -Path C:\Template
$Folders = Get-ChildItem -Recurse -Path "C:\new_perm" -Filter 'Subfolder*' | Select-Object -ExpandProperty FullName
foreach ($Folder in $Folders) {
   # write the variables found - check if the folder path is correct
   # Write-Output "This foldername is $Folder"
   # convert foldername to a icacls approved path
   $icacls = "$Folder\*"
   # check if the icacls path is correct
   # Write-Output "icacls path is $icacls"
   #set the ACL required on the folder
   Set-ACL -Path $Folder -AclObject $ACL
   # replace all child permissions for the folder
   icacls $icacls /q /c /t /reset
}

谢谢,

乔纳森

只是 运行 icacls "C:\template\*" /q /c /t /reset。没有比这更简单的了。