add-circle-bold add-circle add-square add alarm-bell-1 alert-diamond analytics-pie-2 archive archive arrow-down-1 arrow-down-2 arrow-left-1 arrow-right-1 arrow-up-1 attachment-1 bin-paper-1 book-star button-record check-1 check-circle-1 close close-quote close cog-1 cog common-file-stack copy-paste credit-card-1 diagram-fall-down disable time-clock-midnight download-thick-bottom drawer-send envelope-letter envelope-letter expand-6 expand-6 file-code filter-1 floppy-disk flying-insect-honey folder-file-1 headphones-customer-support hierarchy-9 hyperlink-2 information-circle keyboard-arrow-down keyboard-arrow-up layout-module-1 list-bullets lock-2 lock-unlock-1 love-it messages-bubble-square move-to-top multiple-circle multiple-neutral-1 multiple-users-1 navigation-menu-horizontal navigation-menu network-browser open-quote pencil-1 pencil-write pencil-1 print-text rating-star rating-star remove-circle remove-square-1 search send-email-1 shield-warning single-neutral-actions single-neutral smiley-sad-1 smiley-unhappy smiley-indifferent smiley-smile-1_1 smiley-happy smiley-sad-1 smiley-unhappy smiley-indifferent smiley-happy smiley-thrilled social-media-twitter synchronize-arrows-1 tags-double ticket-1 ticket-1 time-clock-circle undo view-1 view-off view wench

AD Recycle Bin

Source:  

 

Enable Via Active Directory Admin Application (DSAC.exe) 

 

Using PowerShell to Enable 

Using PowerShell to enable the Active Directory Recycle Bin is equally as painless.  You use the following commandlet: 

PowerShell 

Enable-ADOptionalFeature –Identity 'CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=testlab,DC=local' –Scope ForestOrConfigurationSet –Target 'testlab.local'  

1 

2 

Enable-ADOptionalFeature –Identity 'CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=testlab,DC=local' –Scope ForestOrConfigurationSet –Target 'testlab.local' 

  

You also receive the notice in PowerShell to confirm the action. 

 

 

Testing 

I have created a testuser account in a TestOU container.  Let’s simulate an accidental deletion.  As you can see, I am about to delete the testuser account. 

It is now gone! 

 

 

 

Restoring Deleted Object 

To restore the object, we need to be a member of at least the Domain Admins group.  To restore a deleted object, we again utilize PowerShell.  You can see the deleted objects by running the following commandlet: 

PowerShell 

get-adobject -filter {displayname -eq "testuser"} -includedeletedobjects  

1 

2 

get-adobject -filter {displayname -eq "testuser"} -includedeletedobjects 

  

As expected, I see the testuser account. 

  
 

 

To restore the object we can simply run the commandlet: 

PowerShell 

get-adobject -filter {displayname -eq "testuser"} -includedeletedobjects | Restore-ADObject  

1 

2 

get-adobject -filter {displayname -eq "testuser"} -includedeletedobjects | Restore-ADObject 

  

 

 

The object is restored in PowerShell with little fanfare. 

 

 

A quick refresh of the ADUC interface once again shows the testuser object.