I’m trying to write a script that would remove all access permissions from a particular folder and replace them with a new set of permissions.
To remove all permissions I do
- $acl = Get-Acl $folder
- foreach($access in $acl.access){
- $acl.RemoveAccessRuleAll($access) | Out-Null
- }
- Set-Acl $folder $acl
however this doesn’t work for some reason. When debugging I’m doing $acl | fl in line 1 and then after Set-Acl and the result is the same as if RemoveAccessRuleAll() never run.
What do I need to modify to get this to work?