• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Sort the Computers in the ADS according to the file

Hi,

I have a txt file which has the machine names so need a way that a sript in which i have mentioned the OU path.The script has to find all computers in the file and move them to the specified OU.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 2
2 Solutions
 
MikkkCommented:
If I've understand you: You want to move computers form "active directory users and computers" to a new OU according to a computer list on a txt file?
isn't it?
0
 
bsharathAuthor Commented:
Yes you are correct..
0
 
MikkkCommented:
Here is a very good article showing the way to find and move objects from and to OUs:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan05/hey0121.mspx

You only need to build a bucle in vbs that iterates in the file, search the machine and moves it to the new OU.
0
 
oBdACommented:
That should do the trick. Just adjust the "NewOU" and "InputFile" variables according to your needs.
As usual, try with a list of test machines first.

@echo off
setlocal
set NewOU=ou=SomeComputers,ou=SomeOU,dc=your,dc=domain,dc=local
set InputFile=C:\Temp\ComputerMove.txt
for /f "tokens=1" %%a in ('type "%InputFile%"') do (
  dsquery computer -name "%%a" | dsmove -newparent "%NewOU%"
)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now