I’m new to playing around with acl’s in the file system. I can add rights but I can’t figure out how to remove acl’s. Here is the code I have.
$FolderPath = "\\filedirectory" $acl = get-acl $FolderPath #I use this to remove all acl's that are not inherited. When I ouptut $acl.access it does remove them (in this case it just removes one security group with my test) $ACL.access | Where-Object {$_.isinherited -eq $false} | %{ $ACL.RemoveAccessRule($_) } #I get the error when I set-acl. set-acl -path $Folderpath -aclobject $ACL
The error I gets is as follows:
set-acl : AclObject At C:\Users\admin.isilver1\Documents\saveacl\restore_acl.ps1:405 char:9
-
set-acl -path $Folderpath -aclobject $ACL
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidArgument: (System.Collections.Hashtable:Hashtable) [Set-Acl], ArgumentException
- FullyQualifiedErrorId : SetAcl_AclObject,Microsoft.PowerShell.Commands.SetAclCommand
I have scurried the web for information with no luck. Any help would be great.