Example of the goal, the crossout is the same user.
我创建了一个脚本,该脚本基于用户SAMaccount创建了一个文件夹,它的工作原理与它应该的一样,它还对文件夹进行了完全控制,而不是继承。
我的目标是为同一用户设置另一组完全控制权限,但继承自“顶部文件夹”,并且完全控制应仅应用于“仅此文件夹”
到目前为止,我的脚本如下:
$users = Get-ADUser -filter * -SearchBase "OU=Test,OU=Users,OU=Bla Groups,DC=Bla,DC=local" |
Select-Object -ExpandProperty sAMAccountName
ForEach($user in $users)
{
$newPath = Join-Path "c:\Temp\Test" -childpath $user
New-Item $newPath -type directory -Force
$acl = (Get-Item $newpath).GetAccessControl('Access')
$permission = "Bla.local\$user","FullControl",@("ContainerInherit","ObjectInherit"),"None","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $newpath
}