Active Directory account and computer restoration

Active Directory has changed forest functional levels every few years with each iteration adding new features. One of the new features with the 2008 R2 functional level (if enabled) is the Active Directory Recycle Bin. This functionality was available before with the use of LDP and ADSI Edit however the process for restoring accounts has gotten much easier.

Import-Module ActiveDirectory
Get-ADObject -filter {SamAccountName -eq "mydeleteduser"} | Restore-ADObject

Compared to the multiple steps before this is pretty simple.

Now lets attempt to restore a previously deleted computer. First step, get the GUID value

Import-Module ActiveDirectory
Get-ADObject -Filter {(isdeleted -eq $true)-and (Name -like "My_Desktop*")} -IncludeDeletedObjects

Now lets restore the computers

Get-ADObject -Filter {(isdeleted -eq $true) -and (ObjectGUID -eq "Whatever my GUID Value is")} -IncludeDeletedObjects  | Restore-ADObject -TargetPath "CN=Computers,DC=liquidobject,DC=com"

Now the computer has been stored to the built-in computers OU.

Leave a comment

Your email address will not be published. Required fields are marked *