Does not contain a method named 'RemoveAccessRule' RRS feed

  • Question

  • Folks,

    I want to remove the ACLs from the shares present on Domain Controller and getting error 

    Here is the code:

    $Right = [System.Security.AccessControl.FileSystemRights]"FullControl" 
    $InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::None 
    $PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None  
    $objType =[System.Security.AccessControl.AccessControlType]::Allow 
    $objACE = New-Object System.Security.AccessControl.FileSystemAccessRule `
        ("DOMAIN1\anuj", $Right, $InheritanceFlag, $PropagationFlag, $objType) 
    $objACL = Get-ACL "d:\test" 
    Set-ACL "d:\test" -aclobject $objACL


    Method invocation failed because [.....] does not contain method named 'RemoveAccessRule'.

    Thursday, October 11, 2018 9:45 AM


  • $acl = Get-ACL d:\test $acl.Access | Where{$_.IdentityReference -eq 'DOMAIN1\anu'} | ForEach-Object{ $acl.RemoveAccessRule($_) }
    Set-Acl d:\test $acl

    Will not remove inherited ACEs.


    Thursday, October 11, 2018 10:06 AM

All replies