Thursday, January 5, 2017

Restore AD user with SamAccountName or Display name and Restore AD OU..



// Restore AD object by Displayname
Get-Adobject -filter {displayname -eq 'Abc xyz'} -IncludeDeletedObjects | restore-Adobject


// Shows all the Deleted parents and child
Get-Adobject -filter {isDeleted -eq $true -and name -ne 'Deleted Objects'} -includeDeletedObjects -property * | ft msds-lastKnownRDN,lastKnownParents -auto -wrap


// Restore AD OU

Get-ADObject -Filter {msds-lastKnownRDN -eq ' OU name '} -IncludeDeletedObjects | Restore-ADObject


//Restore an object from a filtered list of users
This command finds a deleted user whose SAM account name is pattifuller and restores it.

Windows PowerShell
PS C:\> Get-ADObject -Filter 'samaccountname -eq "pattifuller"' -IncludeDeletedObjects | Restore-ADObject

Note: Forest and Domain function level should be 2008R2  and above, Recycle bin feature should be enable then only the above command will work.

Reference Link.
https://technet.microsoft.com/en-us/library/hh852318(v=wps.630).aspx

No comments:

Post a Comment