Is it possible to recover Active Directory objects that have been deleted?
After removing any object in Active Directory (a user, a group, a computer or an OU), you can restore it. In this article we’ll show how to restore a removed object in AD using PowerShell and graphical tools. Show
First of all, let’s see what happens when you delete an object from the AD. AD behavior when removing objects depends on whether the Active Directory Recycle Bin is enabled or not (it is disabled by default). In both cases, the object is not removed physically, it is only marked as deleted (the isDeleted attribute value is changed to true) and moved to a special Deleted Objects container (it is not displayed in AD mmc snap-ins). However, if the AD Recycle Bin is enabled, all attributes and membership are kept. By default, you can restore a removed object within 180 days (it is defined in the msDS-deletedObjectLifetime domain attribute). If the period is over, the object still remains in the Deleted Objects container, but most of its attributes and links are cleared (Recycled Object). After the tombstoneLifetime period (it is also 180 days by default, but you can increase it), the object is completely removed from AD during an automatic cleanup and cannot be restored (you can only restore such an object from an AD domain controller backup). Active Directory Recycle BinAD Recycle Bin is available in Active Directory starting from Windows Server 2008 R2 functional level. In previous Windows Server versions, you may also restore AD objects, but it requires a complex set of actions using special tools: Check the AD forest functional level (in my example, it is Windows2016Forest):
Make sure that the AD Recycle Bin is enabled for your domain (it is disabled by default):
If the EnabledScope value is not empty, it means that the Active Directory Recycle Bin is enabled for your domain. If you want to enable the Active Directory Recycle Bin, use the Enable-ADOptionalFeature cmdlet:
Note. The AD Recycle Bin must be enabled prior to removing an object from the domain. After enabling the Active Directory Recycle Bin feature, you cannot disable it. How to Restore a Deleted User Account in Active Directory?Let’s try to delete an AD user and then restore them from the AD Recycle Bin. Using the Get-ADUser cmdlet, display the value of the IsDeleted attribute of a user (it is empty):
Then remove the user account:
To find a removed user account in the AD Recycle Bin, use the Get-ADObject cmdlet with the IncludeDeletedObjects parameter:
As you can see, the user was found in the Deleted Objects container. Check the value of the IsDeleted attribute, the container the user was located in prior to being removed (LastKnownParent) and the list of groups the user was a member of:
If you don’t remember the name of the user you have deleted, you can display a full list of objects available in the Active Directory Recycle Bin:
To restore a user account, copy the ObjectGUID value and run the following command:
Or you can restore a user using its SAMAccountName:
Open the
ADUC console ( You can also restore a deleted user account object from the graphical console of the Active Directory Administrative Center.
In the same way, you can restore a deleted group, a computer or a container in Active Directory. To restore a deleted security group:
To restore a computer:
How to Restore a Deleted OU and Its Nested Objects Using PowerShell?For example, you had the Protect object from accidental deletion option disabled for an OU, and you have occasionally deleted the OU with all its users, computers and groups. First of all, you must restore the root OU:
Then restore all nested OUs:
After that, you can restore all deleted objects in the OUs using the LastKnownParent parameter (users, computers, groups and contacts):
Which tools lets you restore a deleted Active Directory object?The Active Directory Recycle Bin enables users to recover deleted Active Directory objects without having to restore them from backup, restart Active Directory Domain Services or reboot domain controllers (DCs).
What happens when you delete an object from Active Directory?The deleted object remains in the Deleted Objects container for a period of time known as the tombstone lifetime. By default, the tombstone lifetime is 60 days, but this value can be changed by the system administrator. After the tombstone lifetime expires, the object is permanently removed from the Directory Service.
Is it possible to retrieve deleted objects later?Right-click the file or folder, and then select Restore previous versions. You'll see a list of available previous versions of the file or folder. The list will include files saved on a backup (if you're using Windows Backup to back up your files) as well as restore points, if both types are available.
Can you recover a deleted Active Directory account?You can use several methods to restore deleted user accounts, computer accounts, and security groups. These objects are known collectively as security principals. The most common method is to enable the AD Recycle Bin feature supported on domain controllers based on Windows Server 2008 R2 and later.
|