Reputation: 9644
I'm using powershell to remove folder permissions. My code is something like this
$folder = "\\myServer\C$\myFolder";
$folder_acl = Get-Acl $folder;
$permission_toDelete = $folder_acl.Access | where{ <# selection operation #> }
$permission_toDelete | Foreach-Object { $folder_acl.RemoveAccessRule($_) }
This code return a lot of True
, but it actually doesn't change permissions. The user I'm using is administrator on that server.
I also tried to remove inheritance with this piece of code $folder_acl.SetAccessRuleProtection($true, $false);
but still have the problem
Upvotes: 1
Views: 1876
Reputation: 126942
All that left is to pipe the current acl (after removal) to the Set-Acl
cmdlet:
$folder_acl | Set-Acl
All True output is the return value of each removed acl. You can suppress it if you want:
$folder_acl.RemoveAccessRule($_) | Out-Null
Upvotes: 3