Active Directory Recycle Bin: Deleted Object Recovery and the Tombstone Lifetime Window

Sooner or later someone deletes an object they should not have. An OU with a dozen service accounts, a user who left and was rehired six weeks later, a group whose membership nobody documented. On Windows Server 2016 and later, the Active Directory Recycle Bin restores those objects with their group memberships, attributes and passwords intact — but only if it was enabled before the deletion, and only within the tombstone lifetime.

This article explains how the Recycle Bin and the tombstone lifetime interact, how to enable the feature safely, how to find and restore objects from PowerShell, and what to do when the deleted item is older than the window.

Enabled is a one-way switch

In Windows Server 2008 R2 the Recycle Bin could be enabled through a forest-wide operation that could not be undone, and the UI warned about it heavily. Since Windows Server 2012 R2 that caveat is gone: enabling the feature is still irreversible, but it is now fast, safe and does not require the whole domain to be reanimated. The reason it cannot be turned off is structural — once objects are soft-deleted, the directory keeps the deleted-object metadata that a non-recycled forest does not maintain, and there is no clean way to purge it.

Practical consequence: there is no reason to leave it disabled. The only real argument against enabling it was the old heavy-weight conversion, and that has not been true for a decade.

Checking state and enabling it

Check whether it is already on before changing anything, because it is common for a domain to have been enabled years ago and forgotten.

Import-Module ActiveDirectory
Get-ADOptionalFeature -Filter 'Name -like "Recycle Bin Feature"' |
  Select-Object Name,EnabledScopes,FeatureScope,IsOrphaned

EnabledScopes should list your forest’s head domain. If it is empty, enable it on the forest root:

Enable-ADOptionalFeature -Identity 'Recycle Bin Feature' `
  -Scope ForestOrConfigurationSet `
  -Target (Get-ADForest).RootDomain `
  -Confirm:$false

The cmdlet requires Enterprise Admin (or equivalent rights at the forest configuration container) because it changes a forest-wide setting. Allow replication to converge before you test, and do the test on a disposable object in a test OU. A common mistake is enabling the feature and immediately deleting a test user, then restoring it on the same DC and assuming all DCs are consistent. They are not, for a few minutes.

Deletion, soft deletion and the tombstone lifetime

With the Recycle Bin disabled, a deleted object becomes a tombstone: its attributes are stripped, it keeps only a skeleton record, and it is gone for good. With the Recycle Bin enabled, a deletion becomes a soft delete: the object is moved under the Deleted Objects container, its attributes are preserved, and it can be restored while it is still alive in the directory subsystem.

The window is governed by the tombstone lifetime, a forest-wide setting that defaults to 180 days in domains created by Windows Server 2003 SP1 and later. Check it, do not assume it:

(Get-ADObject -Identity "CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,$((Get-ADForest).RootDomain)" `
  -Properties tombstoneLifetime).tombstoneLifetime

A blank result means the default of 180 days is in effect. Changing this value is possible but has real consequences: a longer tombstone lifetime means a longer window for stale DCs to reintroduce old data, which is precisely the failure mode that causes lingering objects. Values under 60 days are risky for domains with slow replication links or offline DCs. If someone extended it to 365 days “to be safe”, the correct response is to understand why before shortening it back.

Finding what was deleted

Deleted objects live under CN=Deleted Objects,<domain DN>. They are invisible to normal LDAP filters unless you use the control that requests them, which is why a plain Get-ADUser -Filter * shows nothing after a deletion. PowerShell’s -IncludeDeletedObjects switch handles the mechanics:

# Everything deleted in the last 24 hours
$cutoff = (Get-Date).AddDays(-1)
Get-ADObject -Filter {whenChanged -ge $cutoff} -IncludeDeletedObjects `
  -Properties whenChanged,lastKnownParent,isDeleted,objectClass |
  Where-Object isDeleted -eq $true |
  Select-Object Name,ObjectClass,DistinguishedName,lastKnownParent,whenChanged |
  Sort-Object whenChanged -Descending

Filtering on whenChanged is deliberately loose. A soft-deleted object’s modification time reflects the deletion, but the search control also returns objects that were deleted and restored, and you need the isDeleted filter to exclude them. For a targeted search, use -LDAPFilter "(isDeleted=TRUE)(&(objectClass=user)(sAMAccountName=bjsmith))" — much faster on a large directory than pulling everything and filtering in PowerShell.

Restoring an object and its parent OU

Restore requires the distinguished name of the deleted object, not its common name. If the object was in an OU that was also deleted, restore the OU first — an object cannot be restored into a parent that does not exist.

$deleted = Get-ADObject -Filter 'sAMAccountName -eq "bjsmith"' -IncludeDeletedObjects
# Restore the parent OU if necessary
Restore-ADObject -Identity "OU=Contractors,DC=corp,DC=local" -ErrorAction SilentlyContinue
Restore-ADObject -Identity $deleted.DistinguishedName

Restore-ADObject restores the object to the parent recorded in lastKnownParent. If that parent has been renamed or moved, the restore fails with “the parent does not exist”; in that case restore with -TargetPath pointing to an existing OU, then move the object afterwards. Restoring into a temporary OU and then relocating is also the safe pattern when the original parent has since had access-control changes you need to review.

Group objects are the interesting case. A deleted group that had members will restore with its member attribute intact, but each member object must also still exist — restoring a group whose members were deleted separately gives you an empty group. Restore members first, then the group, or restore all of them and accept a brief window where the group is incomplete.

Restoring a deleted OU subtree

When an entire OU is deleted, every child object is soft-deleted along with it. You cannot restore the tree in one cmdlet call, but you can restore it in dependency order — parents before children. A reliable approach is to sort the deleted objects by the depth of their distinguished name:

Get-ADObject -Filter 'isDeleted -eq $true -and lastKnownParent -like "*OU=Projects*"' `
  -IncludeDeletedObjects -Properties lastKnownParent |
  Sort-Object { ($_.DistinguishedName -split ',').Count } |
  ForEach-Object {
    try { Restore-ADObject -Identity $_.DistinguishedName -ErrorAction Stop
          Write-Host "restored $($_.Name)" }
    catch { Write-Warning "failed $($_.Name): $_" }
  }

Depth sorting works because a child’s DN is always longer than its parent’s. Objects restored into a parent that has not yet been restored will fail, then succeed on a second pass, so wrapping the whole loop in a retry is a pragmatic belt-and-braces measure for large trees.

What the Recycle Bin does not bring back

The Recycle Bin covers objects, not the things attached to them:

  • Passwords in some scenarios. The password hash survives, but if the account was reset between deletion and restore, the reset is what you get back.
  • Deleted objects are not visible to standard replication. A restore on one DC may take a full replication cycle to appear elsewhere, and restoring on a DC that has not yet received the deletion is a no-op that looks like success.
  • Anything deleted before the feature was enabled. No tombstone metadata exists; the object is simply gone.
  • Deleted GPOs and some system objects. Group Policy containers in SYSVOL are not part of AD and have their own backup and restore path.

For objects past the tombstone lifetime, or for a domain where the feature was never enabled, the only option is an authoritative restore from a system-state backup, which means restarting a DC in Directory Services Restore Mode and marking the restored objects authoritative so they replicate out. That is a much larger operation than a Restore-ADObject call, and it is the reason that enabling the Recycle Bin is the cheapest insurance policy in the entire Windows Server toolkit.

A short checklist for a Windows VPS domain controller

  • Confirm EnabledScopes is populated on the Recycle Bin feature.
  • Record the effective tombstone lifetime and keep it at 180 days unless a documented requirement says otherwise.
  • Enable AD audit policy for object deletion so you know who deleted what.
  • Keep a system-state backup as the fallback for objects older than the window.
  • Test a restore on a disposable user at least once a year, on a non-production OU.

On a small Windows VPS running Active Directory for a handful of users, this is a two-minute configuration change and a ten-minute test. Compared to a Directory Services Restore Mode recovery on a production domain, it is the difference between an afternoon and a very long night.

Deploying AD on a single Windows VPS makes this configuration mandatory rather than optional, because a forest restore from backup on one server is a long afternoon. The hosting overview covers the snapshot and restore options available per plan if the tombstone window has already lapsed.

Leave a Comment