Remove all acls from folder issue

Trying to remove all acl permissions from folder then add specific ones i want. I got it so I got the users i wanted added however it wont remove all the permissions first.

$Safetypath= “$pathSAFETY”

$Safetyacl= Get-ACL $Safetypath

$User1= “domainsite-safety”

$User2= “domainESG_accounting”

$Safetyacl.SetAccessRuleProtection($True, $True)

$Safetyacl.Access | ?{ $_.IdentityReference -Like “**” } | %{$Safetyacl.RemoveAccessRule($_)}

$AR1= New-Object system.Security.AccessControl.FileSystemAccessRule($User1,”Modify”,”ContainerInherit, ObjectInherit”, “None”, “Allow”)

$AR2= New-Object system.Security.AccessControl.FileSystemAccessRule($User2,”Modify”,”ContainerInherit, ObjectInherit”, “None”, “Allow”)



Set-ACl $Safetypath $Safetyacl

I just want it so those two users are added to the security and nothing else. not system not administrator nothing.

submitted by /u/chipper420
[link] [comments]

Leave a Reply