locked
Moving AD computers from .txt file in bulk RRS feed

  • Question

  • I have a list of computer names I would like to move within AD (2008 R2), using the search feature it seems I can only locate and move one at a time, I have also discovered the ADAC but not sure if that can handle a search like that either.

    I already have a text file containing the computer names I want moved, I just want to move them all at once into another OU.

    Friday, June 22, 2012 1:49 PM

Answers

  • If you are using R2, you have access to the AD modules of Powershell.  You can use Move-ADObject to achieve your goal.

    Grant Ward, a.k.a. Bigteddy

    • Marked as answer by Bill_Stewart Friday, July 6, 2012 9:07 PM
    Friday, June 22, 2012 2:04 PM

All replies

  • If you are using R2, you have access to the AD modules of Powershell.  You can use Move-ADObject to achieve your goal.

    Grant Ward, a.k.a. Bigteddy

    • Marked as answer by Bill_Stewart Friday, July 6, 2012 9:07 PM
    Friday, June 22, 2012 2:04 PM
  • This works fine for one computer:

    Import-Module ActiveDirectory $LISTPC = Get-Content C:\temp\LISTPC.txt

    $LISTPC|Foreach{Get-ADComputer $_|Move-ADObject -TargetPath "OU=Computer,OU=OUNAME,DC=DCNAME,DC=DCNAME,DC=net"}

    but when I added multiple computer names into the "LISTPC.txt" file I get the following error:

    Get-ADComputer : Cannot bind parameter 'Identity' to the target. Exception setting "Identity": "Cannot validate argumen
    t on parameter: 'Identity'. The argument is null or empty. Supply an argument that is not null or empty and then try th
    e command again."
    At line:1 char:31

    Friday, June 22, 2012 5:41 PM
  • What if you do this:
    $LISTPC | Get-ADComputer | Move-ADObject -TargetPath "OU=Computer,OU=OUNAME,DC=DCNAME,DC=DCNAME,DC=net"

    ?


    Grant Ward, a.k.a. Bigteddy



    • Edited by Bigteddy Friday, June 22, 2012 5:51 PM
    Friday, June 22, 2012 5:48 PM
  • I've just tested this on my test domain, and it works:

    gc comps.txt | Get-ADComputer | Move-ADObject -WhatIf -TargetPath 'ou=test,dc=contoso,dc=com' 


    Grant Ward, a.k.a. Bigteddy

    Friday, June 22, 2012 5:56 PM
  • Well I hate to admit it but I think I just had an extra space at the end of the command, I will test further and keep you posted.
    Friday, June 22, 2012 6:02 PM
  • Thank you
    Monday, April 1, 2019 8:37 AM
  • Thank you

    Please do not reactivate ancient threads. Especially when you don't provide any helpful information for the discussed issue.

    Thanks.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Monday, April 1, 2019 8:49 AM