No announcement yet.

Move a list of hosts to another OU- Scripting

  • Filter
  • Time
  • Show
Clear All
new posts

  • Move a list of hosts to another OU- Scripting

    Hello All,

    I have a around 400 disabled computer accounts in our AD 'Computer' container, which is spread among 900 active and inactive computer accounts. It's hard to select them one by one and move to another OU for administration. I have managed all those disabled computers listed in a text file.

    Is there any script I can run against these disabled computers to move to a target OU, using the list text file?
    Insaf Muhammed
    System Admin
    Never break four things in life: TRUST, PROMISE, RELATIONS & HEART. Cause when they break they don't make noise but pains a lot

  • #2
    Re: Move a list of hosts to another OU- Scripting

    Can't you simply use 'Saved Queries' to find the disabled computers -> select 'm all and drag-drop the selection to the new OU ?

    sample Saved Queries,
    Edit Query:
    Name: "Disabled Computers in container domain.local/Computers"
    Description: "Find Disabled Computers in container domain.local/Computers"
    Query root: "...\Computers"
    Define query:
    Custom search => Advanced tab

    scripted solution:

    When the text_file contains the "Common Names" of the computers (???), you can use this Batch,
    For /F "usebackq delims=" %%* in ("computers.txt") Do call :Move_Computer %%*
       :Move_Computer  + + + Subroutine + + +
       dsmove.exe "cn=%*,cn=computers,dc=domain,dc=local" -newparent "ou=new organizational unit,dc=domain,dc=local"
       exit /b 0

    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts


    • #3
      Re: Move a list of hosts to another OU- Scripting

      I would agree that you dont need a script or tool to do this... but in the interest of plugging my own software (which is completely free, so I hope this isn't considered advertising or anything against forum rules) you can use this program that I wrote to do it with ease
      The program is called AD Tidy and I actually wrote it to help clean up stale / inactive accounts but it can also just be used to search for accounts and perform actions on them in bulk - one such action is "Move" which unsurprisingly lets you move them to another OU. There's also the option in the Search Settings to tell it to only find disabled accounts and only search in a particular OU/Container, so that should easily do what you are after You can find more info and a free download link here:

      Hope it helps!
      Last edited by chris128; 2nd September 2010, 00:23.
      Software for IT Pros that I've written:

      My blog: