How to Use PowerShell to Automate Active Directory Tombstone Reanimation

The Challenge of Deleted Active Directory Objects

In a Microsoft Active Directory (AD) environment, when a user, computer, or group object is deleted, it is not immediately removed from the database. Instead, most of its attributes are stripped, and the object is moved to a hidden container known as the Deleted Objects container. At this stage, the object is referred to as a “tombstone.”

While the Active Directory Recycle Bin (introduced in Windows Server 2008 R2) is the preferred method for recovering deleted objects—because it preserves all attributes and group memberships—many legacy environments or specific domains may not have the AD Recycle Bin enabled. In such cases, administrators must rely on Tombstone Reanimation to recover the deleted object. This process brings the object back to life, although stripped of non-essential attributes.

Understanding Tombstone Lifetime

A tombstone does not exist indefinitely. It is kept in the database for a period determined by the tombstoneLifetime attribute of the Directory Service configuration. By default, in modern Windows Server environments, this lifetime is 180 days. Once this period expires, the garbage collection process permanently removes the object from the database.

Tombstone reanimation must occur within this 180-day window.

Step 1: Enabling the LDP Utility

Traditionally, administrators used the graphical ldp.exe tool to reanimate tombstones. However, doing this for multiple objects or automating the process requires PowerShell. Under the hood, PowerShell leverages the .NET Framework’s System.DirectoryServices namespace to interact directly with the LDAP provider.

Step 2: Searching for Deleted Objects via PowerShell

To find a deleted object, we cannot use standard AD cmdlets like Get-ADUser without special parameters, because deleted objects are hidden from normal LDAP queries.

We must use the Get-ADObject cmdlet and explicitly instruct it to include deleted objects.

Import-Module ActiveDirectory
$DeletedUser = Get-ADObject -Filter 'isDeleted -eq $true -and Name -like "*John Doe*"' -IncludeDeletedObjects -Properties isDeleted, lastKnownParent

If the object is found, the $DeletedUser variable will contain the tombstone object, including its ObjectGUID and lastKnownParent (the Organizational Unit where it resided before deletion).

Step 3: Restoring the Object

The actual reanimation process in PowerShell is remarkably straightforward thanks to the Restore-ADObject cmdlet. This cmdlet essentially changes the isDeleted attribute to $false and moves the object out of the Deleted Objects container back to its original (or a specified) location.

# Restore the object to its last known parent OU
Restore-ADObject -Identity $DeletedUser.ObjectGUID

If the original Organizational Unit has also been deleted, the command will fail. In that case, you must restore the object to a different, existing OU using the -TargetPath parameter:

Restore-ADObject -Identity $DeletedUser.ObjectGUID -TargetPath "OU=Recovered Users,DC=company,DC=local"

Step 4: Post-Recovery Cleanup

Because tombstone reanimation does not preserve all attributes, the recovered object will be incomplete. Critically, the following information is lost during the tombstone process:

  • Group Memberships: The user will only belong to Domain Users.
  • Passwords: The account will be disabled, and the password must be reset.
  • Exchange Attributes: Mailbox mappings will be severed.
  • Personal Details: Phone numbers, titles, and addresses are stripped.

Therefore, after running Restore-ADObject, you must immediately enable the account, reset the password, and manually re-add the user to their required security groups.

# Reset password and enable account
$Password = ConvertTo-SecureString "TempPass123!" -AsPlainText -Force
Set-ADAccountPassword -Identity $DeletedUser.ObjectGUID -NewPassword $Password -Reset
Enable-ADAccount -Identity $DeletedUser.ObjectGUID

Conclusion

While the Active Directory Recycle Bin is the gold standard for object recovery, knowing how to script Tombstone Reanimation using PowerShell is a critical fallback skill for Windows Server administrators. By wrapping these cmdlets into a reusable script, you can rapidly respond to accidental deletions even in environments with legacy configurations.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.