Enable Inheritance for Bulk AD Users (Active Directory)

A PowerShell script to enable inheritance for bulk AD users in an OU, with a safer 2026 version: dry run, ACL backup, AdminSDHolder checks and rollback.

Enable Inheritance for Bulk AD Users (Active Directory)

You delegate a permission on an OU, such as password resets for the helpdesk, and it works for most accounts but not all. When you open the Security tab on one of the failing accounts, you find that inheritance is switched off. Fixing one account takes a few clicks. When you need to enable inheritance for bulk AD users, such as hundreds of student accounts, you need a script.

In 2020 I used a short PowerShell script to do exactly that for every account under a specific OU. The idea still works. Below is my original script, followed by a safer version I would use today.

Why accounts lose inheritance

When inheritance is disabled, an account's ACL contains only explicit entries. Anything delegated on the parent OU never reaches it. In my experience this happens after migrations, after accounts are copied from old templates, after manual changes, or because the account belongs to a protected group. That last case is intentional, and I cover it below.

Before you start

  1. Test in a lab or on a small test OU first. This script changes security descriptors on live accounts.
  2. Review the parent OU's delegations. Once inheritance is enabled, each account receives whatever is granted on its OU. Make sure that is what you actually want.
  3. Check for protected accounts. Members of privileged groups have adminCount=1. The AdminSDHolder process deliberately switches their inheritance off again (Microsoft: protected accounts and groups). Leave those accounts alone.
  4. Use the right account. Run the script from an admin workstation that has the ActiveDirectory module installed, using an account with only the rights it needs on that OU.

Enable inheritance for bulk AD users: the original script (2020)

  1. Open PowerShell as an administrator.
  2. Change the -searchbase value to your own OU. The example below uses a placeholder domain.
  3. Run it. The script reports each account it fixes and each account that was already inheriting.
$ADusers = Get-ADUser -ldapfilter "(objectclass=user)" -searchbase "OU=Students,DC=example,DC=com"
ForEach($user in $ADusers)
{
    # Binding the users to DS
    $ou = [ADSI]("LDAP://" + $user)
    $sec = $ou.psbase.objectSecurity

    if ($sec.get_AreAccessRulesProtected())
    {
        $isProtected = $false ## allows inheritance
        $preserveInheritance = $true ## preserve inherited rules
        $sec.SetAccessRuleProtection($isProtected, $preserveInheritance)
        $ou.psbase.commitchanges()
        Write-Host "$user is now inheriting permissions";
    }
    else
    {
        Write-Host "$user Inheritable Permission already set"
    }
}

The key line is SetAccessRuleProtection($false, $true). The first argument turns protection off, which enables inheritance. The second keeps the explicit rules the account already has (.NET documentation).

Update 2026: a safer version

The original still runs, but I would change a few things:

  • Get-ADUser already returns only user objects, so -Filter * is simpler. Be careful reusing (objectClass=user) elsewhere, because on its own it also matches computer objects.
  • Use the account's DistinguishedName explicitly through the AD: drive instead of building an ADSI path from a string.
  • Skip adminCount=1 accounts and report them.
  • Back up each ACL as SDDL before changing it, and do a dry run first.
#Requires -Modules ActiveDirectory
# Example only: test in a lab first. Set $DryRun = $false to apply changes.
Import-Module ActiveDirectory
$SearchBase = 'OU=Students,DC=example,DC=com'
$DryRun     = $true
$Backup     = "C:\Temp\acl-backup-$(Get-Date -Format yyyyMMdd-HHmm).csv"

Get-ADUser -Filter * -SearchBase $SearchBase -Properties adminCount | ForEach-Object {
    $path = "AD:\$($_.DistinguishedName)"
    $acl  = Get-Acl -Path $path

    if (-not $acl.AreAccessRulesProtected) { Write-Host "OK    $($_.SamAccountName)"; return }
    if ($_.adminCount -eq 1) { Write-Warning "SKIP  $($_.SamAccountName) (AdminSDHolder-protected)"; return }

    [pscustomobject]@{ DN = $_.DistinguishedName; Sddl = $acl.Sddl } |
        Export-Csv -Path $Backup -Append -NoTypeInformation

    $acl.SetAccessRuleProtection($false, $true)   # enable inheritance, keep existing rules
    Set-Acl -Path $path -AclObject $acl -WhatIf:$DryRun
    Write-Host ("{0} {1}" -f ($(if ($DryRun) {'WOULD FIX'} else {'FIXED'})), $_.SamAccountName)
}

Make sure the C:\Temp folder exists before you run it, or change the backup path. Otherwise the export will fail.

Run it once with $DryRun = $true and read the output. If the list of accounts looks right, set it to $false and run it again. Set-Acl supports -WhatIf, which is what makes the dry run possible (Set-Acl documentation).

One thing to watch is that adminCount is not always cleared when someone leaves a privileged group. If the script skips accounts that you know are no longer admins, review those few by hand rather than changing the script.

Check it worked, and how to roll back

Verify

This lists any accounts in the OU that still have inheritance disabled. Afterwards, only the skipped protected accounts should remain:

Get-ADUser -Filter * -SearchBase 'OU=Students,DC=example,DC=com' |
    Where-Object { (Get-Acl "AD:\$($_.DistinguishedName)").AreAccessRulesProtected } |
    Select-Object SamAccountName

To check one account in the GUI, open Active Directory Users and Computers and turn on View → Advanced Features. Then open the account and go to Properties → Security → Advanced. The Enable inheritance button should no longer be offered.

Roll back

If something goes wrong, restore each account's ACL from the CSV backup:

# Example only: restores ACLs saved by the script above
Import-Csv 'C:\Temp\acl-backup-YYYYMMDD-HHMM.csv' | ForEach-Object {
    $path = "AD:\$($_.DN)"
    $acl  = Get-Acl -Path $path
    $acl.SetSecurityDescriptorSddlForm($_.Sddl)
    Set-Acl -Path $path -AclObject $acl
}

Quick checklist

Step Done?
Tested on a lab or test OU
Parent OU delegations reviewed
Backup folder exists
Dry run output checked
SDDL backup file saved somewhere safe
Protected (adminCount=1) accounts left alone
Verification query shows no unexpected accounts

The takeaway: enabling inheritance in bulk is a one-line change inside a loop, but treat it like any other permission change. Back up first, do a dry run, and know what the parent OU grants. If you are tidying up delegation across a whole directory and want help, my company Standing provides information security and managed IT services.

Sources & further reading

  1. Get-ADUser (ActiveDirectory module) – Microsoft Learnlearn.microsoft.com
  2. Appendix C: Protected Accounts and Groups in Active Directory – Microsoft Learnlearn.microsoft.com
  3. Set-Acl – Microsoft Learnlearn.microsoft.com
  4. ObjectSecurity.SetAccessRuleProtection – .NET API documentationlearn.microsoft.com
  5. PowerShell support lifecycle – Microsoft Learnlearn.microsoft.com

📝 First written from my own work in 2020; updated and expanded in November 2026 with AI assistance, keeping my original fix. Spotted something wrong? Tell me.

Akam Omer
Written by

Akam Omer

IT leader, engineer and security specialist from Erbil with 20+ years across higher education, telecoms, healthcare and government. Founder of BulkSMSIraq, VerifyWay and Kurd.ai.