How to restore a deleted AD object using PowerShell
Occasionally, one or more active directory (AD) objects may be inadvertently deleted by sys admins. If some conditions are met, it may not be necessary to do a Domain Controller restore. There are easier ways to restore AD objects but the powershell commands below may be integrated in more comprehensive scripts.
For illustration purposes, the domain name is set to support.test.local
Open an elevated Powershell command prompt on the domain controller Type: PS C:\>import-module ActiveDirectory
Note -- if using the Active DirectoryModule for Windows Powershell, this step is not necessary
The AD forest needs to be in Windows2008R2 mode. Get the ADforest mode. PS C:\>get-ADForest Find the ForestMode Property and make sure that it is set to Windows2008R2Forest You can elevate the Forest mode running: