Deleting the wrong OU in Active Directory used to mean an authoritative restore from a system state backup, a Directory Services Restore Mode reboot and a long evening. The Active Directory Recycle Bin keeps deleted objects intact, with their SIDs, group memberships and attributes, for the length of the deleted object lifetime (180 days by default) so they can be restored in seconds. It is still not enabled by default on a new forest, even on Windows Server 2025, so it belongs at the top of the checklist for any domain you inherit.
Applies to Forests at Windows Server 2008 R2 functional level or higher, including Windows Server 2025
Short answer: With the forest at Windows Server 2008 R2 functional level or higher, run Enable-ADOptionalFeature 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target corp.example.com once as an Enterprise Admin; it cannot be turned off again. To restore, find the object with Get-ADObject -Filter 'isDeleted -eq $true -and Name -like "jsmith*"' -IncludeDeletedObjects and pass it to Restore-ADObject, or use the Deleted Objects container in the Active Directory Administrative Center. Restore parent OUs before their children or the restore fails. (Reviewed November 2026.)
Table of Contents
Check prerequisites and enable it
The forest functional level must be at least Windows Server 2008 R2:
Get-ADForest | Select-Object ForestMode, RootDomain
Get-ADOptionalFeature -Filter * | Select-Object Name, EnabledScopes
If EnabledScopes for “Recycle Bin Feature” is empty, enable it as a member of Enterprise Admins. Microsoft documents this operation against the domain controller that holds the domain naming master role, so run it there or add -Server with that DC’s name:
Enable-ADOptionalFeature -Identity 'Recycle Bin Feature' `
-Scope ForestOrConfigurationSet -Target 'corp.example.com' -Confirm:$false
The change is forest-wide and permanent. It replicates to every DC and takes effect once replication converges; objects deleted before enabling it are not recoverable this way because they were already stripped to tombstones. The same switch is available in the Active Directory Administrative Center by selecting the domain in the left pane and choosing “Enable Recycle Bin” from the Tasks pane. If the level is too low, see raise the AD forest and domain functional level safely.
Check the lifetimes before you rely on it
How long the Recycle Bin can help depends on two attributes on the Directory Service object. Read them, along with the DC to run the enable command against:
(Get-ADForest).DomainNamingMaster
Get-ADObject -Identity 'CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=corp,DC=example,DC=com' `
-Partition 'CN=Configuration,DC=corp,DC=example,DC=com' `
-Properties tombstoneLifetime, msDS-DeletedObjectLifetime
An empty msDS-DeletedObjectLifetime means deleted objects stay restorable for the tombstone lifetime. In forests created with Windows Server 2003 SP1 or later that is 180 days; in older forests where tombstoneLifetime was never set, Windows uses 60 days. After that, objects become recycled objects, which the Administrative Center does not show and the Recycle Bin cannot restore.
Two more facts to plan for. The database (NTDS.DIT) grows on every DC once the feature is on, because deleted objects keep all their attributes. And any object deleted before you enable it becomes a recycled object at that moment; the only way back for those is an authoritative restore from a backup taken before you enabled the feature.
Restore a single object
Search the Deleted Objects container, which is hidden from normal queries:
Get-ADObject -Filter 'isDeleted -eq $true -and Name -like "Jane Smith*"' `
-IncludeDeletedObjects -Properties LastKnownParent, whenChanged |
Select-Object Name, ObjectClass, LastKnownParent, whenChanged
Restore it to its original location, or to a new one if the parent OU no longer exists:
Get-ADObject -Filter 'SamAccountName -eq "jsmith"' -IncludeDeletedObjects | Restore-ADObject
Restore-ADObject -Identity "<objectGUID>" -TargetPath "OU=Staff,DC=corp,DC=example,DC=com"
The restored user keeps the same SID, password, group memberships and attributes, so file permissions and mailboxes reconnect without any further work. Computer accounts restore the same way and rejoin the domain transparently, which is the right fix for a machine whose object was deleted by mistake rather than rejoining it.
Restore a deleted OU and its contents
When an entire OU is deleted, its children are deleted with it and each keeps a LastKnownParent pointing at the OU. This short version is only for one OU whose users, groups and computers sit directly inside it, with no OUs below it. It matches by name, so it can also pick up objects from another deleted OU whose name contains Sales, and it does not put nested OUs in order. For nested OUs, or when several OUs were deleted, go straight to the parent-first procedure in the worked example below.
$deleted = Get-ADObject -Filter 'isDeleted -eq $true -and LastKnownParent -like "*OU=Sales*"' `
-IncludeDeletedObjects -Properties LastKnownParent
Get-ADObject -Filter 'isDeleted -eq $true -and Name -like "Sales*" -and ObjectClass -eq "organizationalUnit"' -IncludeDeletedObjects | Restore-ADObject
$deleted | Where-Object ObjectClass -eq 'organizationalUnit' | Restore-ADObject
$deleted | Where-Object ObjectClass -ne 'organizationalUnit' | Restore-ADObject
Check the list in $deleted before restoring anything. For nested OUs, work from the top down: restore the parent OU first, then the objects whose LastKnownParent is the OU you just restored, and repeat one level at a time. The Administrative Center makes this easier: open Deleted Objects, filter by name, select the OU and choose Restore, then repeat for the contents, which will now show their original parent as available.
Worked example: undo a bulk deletion
A cleanup script has just deleted far more than intended: users, groups and a few nested OUs. You know roughly when it ran. First list what came out of the directory in that window, without changing anything:
$since = (Get-Date).AddHours(-2)
$filter = 'isDeleted -eq $true -and -not (isRecycled -eq $true) -and whenChanged -gt $since -and Name -ne "Deleted Objects"'
Get-ADObject -Filter $filter -IncludeDeletedObjects -Properties LastKnownParent, whenChanged |
Sort-Object whenChanged | Select-Object Name, ObjectClass, LastKnownParent, whenChanged
whenChanged is a close approximation of the deletion time. Check the count and the names before you go further, and narrow $since or add ObjectClass to the filter if unrelated deletions show up.
A child cannot be restored while its parent is still deleted. Its LastKnownParent points into the Deleted Objects container until the parent comes back, then changes to the live OU. That makes a simple restore loop possible: each pass restores only the objects whose parent is already live.
for ($pass = 1; $pass -le 10; $pass++) {
$ready = Get-ADObject -Filter $filter -IncludeDeletedObjects -Properties LastKnownParent |
Where-Object { $_.LastKnownParent -notlike '*CN=Deleted Objects*' }
if (-not $ready) { break }
$ready | Restore-ADObject
}
Each pass brings back one more level of the tree, so ten passes cover deep OU structures. An object that fails to restore, for example because a replacement with the same name now exists in the same OU, will show the same error on every pass; restore it separately with -TargetPath or -NewName. To preview a single pass, add -WhatIf to Restore-ADObject. Run the first command again afterwards: it should return nothing.
Protect against the next accident
The Recycle Bin is a safety net, not a substitute for prevention or backups. Tick “Protect object from accidental deletion” on every OU and set it in bulk. It is on by default for new OUs created in Active Directory Users and Computers, the Administrative Center or New-ADOrganizationalUnit, but a script that passes -ProtectedFromAccidentalDeletion $false, or tools that create OUs through raw LDAP such as ldifde or dsadd, leave it off:
Get-ADOrganizationalUnit -Filter * | Set-ADObject -ProtectedFromAccidentalDeletion $true
Keep system state backups of at least two DCs, because the Recycle Bin cannot help with schema damage, a corrupted database or a deletion older than the lifetime. If you need a longer retention, raise msDS-DeletedObjectLifetime on CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=corp,DC=example,DC=com with Set-ADObject, keeping it at or below the tombstone lifetime.
Verify
After enabling, Get-ADOptionalFeature 'Recycle Bin Feature' should list the forest’s configuration partition under EnabledScopes on every DC. Test it once by creating a throwaway user, deleting it, and restoring it with Restore-ADObject; the user should reappear with the same objectSID. A common pitfall is searching with Get-ADUser, which never returns deleted objects; use Get-ADObject with -IncludeDeletedObjects every time.
Common errors and fixes
| Symptom | Cause | Fix |
|---|---|---|
| “The operation could not be performed because the object’s parent is either uninstantiated or deleted.” | You restored a child before its parent OU | Restore the parent first, or restore the child elsewhere with -TargetPath (Restore To in the Administrative Center) |
| The object is missing from Deleted Objects in the Administrative Center | The console lists 20,000 objects by default, or the object is already recycled | Raise the limit (up to 100,000) under Manage » Management List Options, or use Search under this node; query with Get-ADObject to be sure |
| A deleted DNS or Configuration object is not shown at all | The Administrative Center only manages domain partitions | Use Get-ADObject -IncludeDeletedObjects with -SearchBase set to that partition’s Deleted Objects container, then Restore-ADObject |
| Enable Recycle Bin fails | Not run against the domain naming master, or missing Enterprise Admins rights | Run it on the domain naming master; Microsoft also suggests placing the schema master and domain naming master on the same root-domain DC and retrying there |
| The restored user is back on-premises but not in Microsoft 365 | The Entra ID object was hard-deleted, or the next sync has not run | Entra ID keeps soft-deleted users for 30 days by default and restores them on sync; after a permanent delete the cloud object cannot come back |
Until the enable change has replicated to every DC, the feature is not fully working, so a restore on one DC may not be visible on another for a few minutes.
Active Directory Recycle Bin at a glance


Official documentation: Active Directory Domain Services docs, Windows Server documentation.
Related guides: Set up a file server with DFS Namespaces and DFS Replication · How to find the source of Active Directory account lockouts (Event ID 4740) · Configure NTP time sync for the PDC emulator and domain clients.
Frequently asked questions
Does the Active Directory Recycle Bin also restore group memberships?
Yes; because objects are preserved with all linked attributes, a restored user regains every group it was a member of, and a restored group regains its members, as long as those objects still exist.
How long do deleted objects stay in the Recycle Bin?
For the deleted object lifetime, which defaults to 180 days (or the tombstone lifetime on older forests); after that the object becomes a recycled tombstone and can only be recovered from a backup.
Can I disable the Recycle Bin after enabling it?
No; enabling the feature is permanent for the forest, and the only reversal is a full forest recovery, so plan for the slightly larger database and enable it once.
Does restoring a user from the AD Recycle Bin bring back the Microsoft Entra ID account?
Yes, if the account is synced with Microsoft Entra Connect and the cloud object is still soft-deleted (30 days by default). The restored on-premises object keeps its source anchor, so the next sync restores the matching Entra ID user instead of creating a new one. Microsoft recommends enabling the Recycle Bin on synced forests for this reason.
Does the Active Directory Recycle Bin make the database bigger?
Yes. Deleted objects keep all their attributes for the deleted object lifetime, so NTDS.DIT grows on every domain controller in the forest and keeps growing over time. Check free space on the database volume of each DC before enabling it in a large forest.
Maintenance record
This guide changes servers, data or security settings, so we re-check it against current versions on a fixed schedule. Take a backup or snapshot before you start.
- Maintained by
- srvScripts editorial team
- Supported versions
- Forests at Windows Server 2008 R2 functional level or higher, including Windows Server 2025
- Last full review
- Next review
