Share via


Error using Move-ADObject

Question

Tuesday, January 23, 2018 1:08 PM

Hello Guys,

I am trying to use the Move-ADObject cmdlet to move some workstations from one domain to another.

Here my script:

$SourceDomain = "DEV.CIA.COM"
$SourceOU = "OU=ABC,DC=DEV,DC=CIA,DC=COM"
$TargetDomain = "LAB.CIA.COM"
$TargetOU = "OU=XZY,DC=LAB,DC=CIA,DC=COM"
$Computers = (Get-ADComputer -Filter * -SearchBase $SourceOU -Server $SourceDomain).DistinguishedName
foreach ($Computer in $Computers)
{
 Move-ADObject -Identity $Computer -server $SourceDomain -TargetPath $TargetOU -TargetServer DC1.LAB.CIA.COM
 }

However I am getting the following error for each workstation from the source OU :

Move-ADObject : The naming context could not be found
At line:9 char:1

  • Move-ADObject -Identity $Computer -server $SourceDomain -TargetPath $ ...

    + CategoryInfo          : NotSpecified: (CN=WKST1,OU=...DC=DEV,DC=COM:ADObject) [Move-ADObject], ADException
    + FullyQualifiedErrorId : ActiveDirectoryServer:8420,Microsoft.ActiveDirectory.Management.Commands.MoveADObject

Any help is appreciated.

All replies (3)

Tuesday, January 23, 2018 1:35 PM

Hi,

You're trying to move computers between two different forests which is not possible.


Tuesday, January 23, 2018 2:09 PM

Sorry, my fault. I fixed the script. Even in the same forest, I am getting the same error.


Wednesday, January 24, 2018 6:37 AM

Hi,

I agree with Richard, I suggest moving one single computer first to see if it succeeds. Also, please have a try to validate whether the trust relationship between these two child domains is working properly.

If you need further help, please feel free to let us know.

Best Regards,
Albert

Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]