locked
Error using Move-ADObject RRS feed

  • Question

  • 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.


    Tuesday, January 23, 2018 1:08 PM

All replies

  • Hi,

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

    Tuesday, January 23, 2018 1:35 PM
  • This help for Move-ADObject:

    https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee617248(v=technet.10)

    has this example for moving objects from one domain to another.

    Move-ADObject -Identity "CN=Peter Bankov,OU=Accounting,DC=Fabrikam,DC=com" -TargetPath "OU=Accounting,DC=Europe,DC=Fabrikam,DC=com" -TargetServer "server01.europe.fabrikam.com"
    But the domains should be in the same forest, as TobyU noted.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, January 23, 2018 1:42 PM
  • Sorry, my fault. I fixed the script. Even in the same forest, I am getting the same error.


    Tuesday, January 23, 2018 2:09 PM
  • 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 tnmff@microsoft.com

    Wednesday, January 24, 2018 6:37 AM