locked
Can't Move Computer to Different OU RRS feed

  • Question

  • I have a computer that I renamed. It isn't in the organizational unit I'd like. In fact I don't see it anywhere in the AD, but it's there and it's on the domain just fine. It's listed as being in the Computers container:

    CN=ESABO-PC,CN=Computers,DC=occf2,DC=local

    I only see it in AD when doing a find command, but I don't know how to move it to the OU I'd like to, which is OCCF Computers. Normally I'd find it and just drag it to the container I'd like, but I can't see it, other than doing a find, to move it. And when it's found and I right click move and designate the new OU, it doesn't do anything. I'm at a loss as to why it doesn't show in Computers when everything says it should be there. Any ideas?

    Sunday, April 22, 2018 2:37 PM

Answers

  • try without the single quotes in the LDAP filter (and make sure that the OU name is correct):

    $target = Get-ADOrganizationalUnit -LDAPFilter "(name=OCCF Computers)"

    get-adcomputer ESABO-PC | Move-ADObject -TargetPath $target.DistinguishedName

    hth
    Marcin

    • Marked as answer by js0873x Sunday, April 22, 2018 8:48 PM
    Sunday, April 22, 2018 8:15 PM

All replies

  • Hi js0873x,

    You can use these powershell commands:

    $target = Get-ADOrganizationalUnit -LDAPFilter "(name='OCCF Computers')"
    
    get-adcomputer ESABO-PC | Move-ADObject -TargetPath $target.DistinguishedName


    Check this post for reference https://blogs.technet.microsoft.com/heyscriptingguy/2012/03/01/the-easy-way-to-use-powershell-to-move-computer-accounts/

    Regards

    Simon


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    Sunday, April 22, 2018 3:17 PM
  • Hi js0873x,

    You can use these powershell commands:

    $target = Get-ADOrganizationalUnit -LDAPFilter "(name='OCCF Computers')"
    
    get-adcomputer ESABO-PC | Move-ADObject -TargetPath $target.DistinguishedName


    Check this post for reference https://blogs.technet.microsoft.com/heyscriptingguy/2012/03/01/the-easy-way-to-use-powershell-to-move-computer-accounts/

    Regards

    Simon


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    Well, I'm not the world's best on PowerShell, but here's what I did:

    I started the Active Directory Module for Windows Powershell

    I ran the first command:

    get-adcomputer ESABO-PC | Move-ADObject -TargetPath $target.DistinguishedName

    and it came right back with a command prompt

    I ran the 2nd command and it came back with this:

    Move-ADObject : Cannot validate argument on parameter 'TargetPath'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
    At line:1 char:52
    + get-adcomputer ESABO-PC | Move-ADObject -TargetPath <<<<  $target.DistinguishedName
        + CategoryInfo          : InvalidData: (:) [Move-ADObject], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.MoveADObject

    Any ideas?

    Sunday, April 22, 2018 3:51 PM
  • did you run the first command? (the one starting with $target)

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    Sunday, April 22, 2018 4:48 PM
  • did you run the first command? (the one starting with $target)

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. Regards Simon Disclaimer: This posting is provided AS IS with no warranties or guarantees, and confers no rights.

    I sure did. I'll paste a screenshot.

    Sunday, April 22, 2018 5:39 PM
  • try without the single quotes in the LDAP filter (and make sure that the OU name is correct):

    $target = Get-ADOrganizationalUnit -LDAPFilter "(name=OCCF Computers)"

    get-adcomputer ESABO-PC | Move-ADObject -TargetPath $target.DistinguishedName

    hth
    Marcin

    • Marked as answer by js0873x Sunday, April 22, 2018 8:48 PM
    Sunday, April 22, 2018 8:15 PM
  • try without the single quotes in the LDAP filter (and make sure that the OU name is correct):

    $target = Get-ADOrganizationalUnit -LDAPFilter "(name=OCCF Computers)"

    get-adcomputer ESABO-PC | Move-ADObject -TargetPath $target.DistinguishedName

    hth
    Marcin

    Worked like a champ! Thx.
    Sunday, April 22, 2018 8:48 PM