Everything between <..> needs to be replaced or contains your specific environmental information.
To enable the AD recycle bin you first need to upgrade all your DC’s to Windows Server 2008 R2. Next you need to bring your domain and forest to 2008 R2 fictional level. Once your forest level is at the 2008 R2 functional level you can then enable the recycle bin feature.
First you need to be member of the Enterprise Admin group to be able to enable this feature. Next you need to start the Active Directory Module for Windows PowerShell as an administrator. Right click and run as an administrator. It needs to be the PowerShell environment with the AD module loaded.
First you should query to see if the recycle bin is enabled or not. To retrieve this information execute the following PowerShell command:
Get-ADOptionalFeature -filter {name -like "*"}
You will receive the following information:
DistinguishedName : CN=Recycle Bin Feature, CN=Optional Features, CN=Directory Service, CN=Windows NT, CN=Services, CN=Configuration, DC=<Domain>, DC=<Root>
EnabledScopes : { }
FeatureGUID : 766ddcd8-acd0-445e-f3b9-a7f9b6744f2a
FeatureScope : {ForestOrConfigurationSet}
IsDisableable : False
Name : Recycle Bin Feature
ObjectClass : msDS-OptionalFeature
ObjectGUID : <YourGuid>
RequiredDomainMode :
RequiredForestMode : Windows2008R2Forest
The most important option to pay attention to is the EnableScoop. If this option is empty, as it is in this case, than the recycle bin has not been enabled.
To enable the recycle bin you need to execute the following command:
Enable-ADOptionalFeature -Identity 'CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration,DC=<Domain>,DC=<Root>' -Scope ForestOrConfigurationSet -Target '<Domain.Root>'
Now rerun the command Get-ADOptionalFeature -filter {name -like "*"}. You should now receive the following output:
DistinguishedName : CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT, CN=Services, CN=Configuration, DC=<Domain>, DC=<Root>
EnabledScopes : {CN=NTDS Settings, CN=<SERVERNAME1>, CN=Servers, CN=<SITE1>, CN=Sites, CN=Configuration, DC=<Domain>, DC=<Root>, CN=NTDS Settings, CN=<SERVERNAME3>, CN=Servers, CN=<SITE2>, CN=Sites, CN=Configuration, DC=<Domain>, DC=<Root>, CN=NTDS Settings, CN=<SERVERNAME2>, CN=Servers, CN=<SITE1>, CN=Sites, CN=Configuration, DC=<Domain>, DC=<Root>, CN=Partitions, CN=Configuration, DC=<Domain>, DC=<Root>}
FeatureGUID : 766ddcd8-acd0-445e-f3b9-a7f9b6744f2a
FeatureScope : {ForestOrConfigurationSet}
IsDisableable : False
Name : Recycle Bin Feature
ObjectClass : msDS-OptionalFeature
ObjectGUID : <YourGuid>
RequiredDomainMode :
RequiredForestMode : Windows2008R2Forest
Now you see that the EnableScoop option is filled with your DC objects. This is dependent on how quickly you execute this command. If you execute it right after you enabled the recycle bin you will only see the servers in your current site. To be able to see all the servers you will have to wait until all the sites have replicated their information with your site. This is dependent on you typology.
I’m not going to explain how to restore an AD object with PowerShell because I can highly recommend downloading the following freeware tool http://www.overall.ca/ADRecycleBin. This is a graphical tool to restore deleted AD objects. You do need to run the tool with Domain Admin privileges. If you still want to know how to restore an AD object through PowerShell please see the following link for more information Active Directory Recycle Bin Step-by-Step Guide