Using the Windows 2008 R2 Active Directory Recycling Bin
So let's see how that Recycle Bin works. First we need to enable it. It is good to note again. You cannot enable this unless all your DC's are windows 2008 R2 and you raise your forest functional level to 2008 R2. For me in the lab, this is simple, in a real environment, this takes days and weeks of planning and effort to get to this step!
Some generic information about this feature:
- Deleted items are retained for up to 180 days by default. I imagine that this can be edited to be shorter or longer somehow, but I was not able to find this.
- You can view and restore items using either LDP or Powershell, but I was NOT able to get Powershell to work. More on that below.
From this article:
http://technet.microsoft.com/en-us/library/dd379481.aspx
There are two ways to add the Recycle Bin. Powershell or LDP as specified in that article. I like powershell a LOT, so I will go with this. Keep in mind, "regular" powershell will not recognize these commands, you need to choose to use the AD powershell from under your administrative tools.

So I guess it's time to put on my silly admin hat.
Create a new user:
Much more information on a single screen here now:
Do note the "Protect object from accidental deletion" If you google this, you will see it actually has NOTHING to do with the AD recycle bin, its a pre-existing feature.
So first, we need to use LDP to view the recycle bin as per this article: http://technet.microsoft.com/en-us/library/dd379509.aspx
Here, I have connected and bound and am opening tree view:
And then I can see the deleted objects:
So let's delete an unfortunate soul:
After doing this, I can refresh the LDP window and see this:
So we right click the user and choose Modify:
So we are presented with the modify dialog, and I added "isDeleted" and selected delete:
Then hit Enter:
Then, enter distinguishedName and for the value, put the original DN of the object and choose replace.
Then hit enter. Clearly here, you are building a list of changes to be performed to undelete the object.
Most importantly, check the "extended" check box. Then you can hit run.
The screen will stay up, but you can view the main LDP window to see the status of this change:

Then, refresh your AD Administrative Center, and our "Test User" object is there again!
Now, let's nuke him again and restore him from Powershell!
This is where I seemed to hit a glitch of some sort:
From the Microsoft Help page:

Obviously, the command should be "Get-ADObject -filter" but hey missed a space there. This code will not work for me. Actually, even if I do "get-ADObject" with no parameters, I should get back a long list of objects. Instead I get this. Granted, this is beta code, and I might be missing something, but I couldn't get this working as cleanly as the LDP instructions above. I guess it's a good thing there are more than one way to recover these!

- I later solved this issue in another post on recovering objects using Powershell.
Labels: windows 2008 R2
































































