top of page
Writer's pictureUzair Ansari

Restore active directory objects using powershell

Updated: Nov 5, 2021

Have you been through situation where you have accidently deleted active directory object? Or the AD cleanup process of deleting stale AD objects had the working AD object in the delete list and have unintentionally deleted that working AD object? Well the AD object isn't really deleted. It's still present in the AD for a limited period of time. This process is known as tombstone life. Though there are other ways you can restore AD object, powershell proves to be most reliable and quick in restoring AD object. Below given powershell command can be used to restore AD object.


Get-ADObject -Filter 'samaccountname -eq "jSmith"' 
-IncludeDeletedObjects | Restore-ADObject

jSmith is the samAccountName of the AD object that is being restored. The Get-ADObject searches for the account that is mentioned in the samAccountName field. The -IncludeDeletedObjects parameter instructs to search in the deleted objects container. This container holds all the deleted AD objects. And then once the object is found, it is sent to the Restore-AdObject.



The account with which this command is executed should be having proper permissions in place. Specifically reading deleted objects container and creating AD objects permission.



For restoring AD objects through GUI, you can refer this link.

Comments


bottom of page