Steps to restore deleted Active Directory users using PowerShell
This article explains how to restore a deleted AD user account using PowerShell and RecoveryManager Plus, the Active Directory backup and recovery tool. The GUI-based RecoveryManager Plus makes it easy for any administrator to restore a deleted account in a few simple clicks, without having to write a single line of PowerShell script.
Steps to restore deleted user objects using PowerShell:
- Note: You have to enable Active Directory Recycle Bin before you can restore deleted objects using PowerShell. Once enabled, Recycle Bin cannot be disabled.
- Step 1: Identify the distinguished name of the user object to be restored by executing the following PowerShell script.
- Step 2: Execute the following script to restore the deleted user object.
(Get-ADObject -SearchBase (get-addomain).deletedobjectscontainer -IncludeDeletedObjects -filt er "samaccountname -eq '%OLD_NAME%'") | Restore-ADObject -NewName "$.Name"
Steps to restore deleted user objects using RecoveryManager Plus:
- Step 1: Navigate to Active Directory > Recycle Bin.
- Step 2: Select the object you wish to restore and click Restore.
That’s all it takes. No PowerShell scripting. Easy, GUI-based point-and-click restore for user objects with advanced options such as advanced search and automatic membership restoration.
Limitations of using PowerShell to restore deleted AD user accounts:
- The native AD Recycle Bin has to be enabled for user restoration using PowerShell.
- It is not possible to preview the properties of the user account before restoring it.
- Multiple users cannot be restored simultaneously.
- If the deleted user account was present in an OU which has also been deleted, the OU has to be restored before the user account can be restored.