Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Remove ACL Entry from an OU

$
0
0

Hi

Is there a way I can remove a user (in this case "NT Authority\Authenticated Users") from an OU using Powershell. Inheritance is blocked.

Ive attempted to the below but it doesnt seem to work: Any suggestions?

    $acl = Get-Acl -Path "Path to OU"    
foreach($acc in $acl.access ) 
{ 
    $value = $acc.IdentityReference.Value 
    if($value -match "NT Authority\Authenticated Users") 
    { 
        $ACL.RemoveAccessRule($acc) | Out-Null 
        Set-Acl -Path "Path to OU" -AclObject $acl -ErrorAction Stop 
        Write-Host "Remove ACL Entry: $value  form" 
    } 
}"


Viewing all articles
Browse latest Browse all 21975

Trending Articles