How to Activate and Use Active Directory Recycle Bin with PowerShell


Important Note:This acction is irreversible, so when you activate the Active Directory Recycle Bin Feature you will not be able to disable this feature!

 

First open Active Directory Module for Windows PowerShell (You can find it on your DC Administrative Tools).

Then type this command:

Enable-ADOptionalFeature –Identity “CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration, DC=domain,DC=com” –Scope ForestOrConfigurationSet –Target “domain.com”

You need to change “DC=domain,DC=com” and “-Target “domain.com” to your domain information.

 

If youreceive this error:

image

 

You just need to run the Active Directory Module for Windows PowerShell with your Domain Admin and with “Run As Administrator”.

 

After do this here is the result:

image

 

Now the Active Directory Recycle Bin is enabled,and if you need to restore an ADObject you just need to list the recycle bin objects:

Get-ADObject -SearchBase “CN=Deleted Objects,DC=domain,DC=com” -ldapFilter “(objectClass=*)” -includeDeletedObjects | FT ObjectGUID,Name  -A

 

image

 

Then you can recover the Object using this command:

Restore-ADObject -Identity dd83eec4-f136-4aed-b1e1-437f7fed4f92

image

 

 

Hope you enjoy ;)

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: