Restore objects in Active Directory using Recycle Bin and Powershell

To see the Deleted Objects container you must run the command as Domain Administrator.

This is one of many examples how to restore an object from Recycle Bin using Powershell

Get-ADObject -SearchBase 'CN=Deleted Objects,DC=domain,DC=com' -Filter {name -like '*Test*' } -IncludeDeletedObjects

This will return all object in Recycle Bin with the namn Test somewhere in the name. In some case you may get a lot of objects in return. To specify a single object you can use i.e. ObjectGUID.

Get-ADObject -SearchBase 'CN=Deleted Objects,DC=domain,DC=com' -Filter {name -like '*Test*'} -IncludeDeletedObjects</span> <strong>| Where {$_.ObjectGUID -eq 'e143e453-a8a8-47a9-b1fc-7f67e8b2a668'}

This will return only one single object and now it’s time to restore it.

Get-ADObject -SearchBase 'CN=Deleted Objects,DC=domain,DC=com' -Filter {name -like '*Test*' } -IncludeDeletedObjects | Where {$_.ObjectGUID -eq 'e143e453-a8a8-47a9-b1fc-7f67e8b2a668'}| Restore-ADObject

Now you should see the object in ADUC on the samt location as when you deleted it.

This entry was posted in Active Directory, Powershell and tagged , , . Bookmark the permalink.