you would then use the same list to get a
FOR /F %i IN (mylistofnames.txt) DO dsquery user forestroot -scope subtree -name %i -o dn|dsmove -newparent OU=NEWDEST,DC=FQDN
where OU=NEWDEST,DC=FQDN is the FQDN of the new OU you want to move to.
please note your list of names must be unique. Test before doing this by ensuring the command below
FOR /F %i IN (mylistofnames.txt) DO dsquery user forestroot -scope subtree -name %i -o dn >> textfilename.txt
gives you a list of DNs you really want to disable/move. Please check syntax and test before doing for real on production servers!
Regards
M@
You have a list to use as input file. Read from that list and get the DN of each user. Then pass the DN to the script listed in this sample: http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=trueOrIn a batch file, do a For loop and read in the input file, then use dsquery to get the DN and pass that to dsmod to disable the accountsSomething like:FOR /F %%i IN (mylistofnames.txt) DO dsquery user forestroot -scope subtree -o dn|dsmod user -disabled Yes
Sincerely,
_____
(, / | /) /) /)
/---| (/_ ______ ___// _ // _
) / |_/(__(_) // (_(_)(/_(_(_/(__(/_
(_/ /)
(/
Microsoft MVP - Directory Services
www.akomolafe.com - we know IT
-5.75, -3.23
Do you now realize that Today is the Tomorrow you were worried about Yesterday? -anon
From: Ramon Linan
Sent: Fri 8/25/2006 11:16 AMSubject: [ActiveDir] disable 200 usersHi,
I have been given a list of 200 users to disable, and move to another OU.
The users are not currently in the same OU but in many different OU.
I am trying to use the txt file that contains the list of users to be disable.
How can I do this?
I was trying to use the query tool that comes with AD users and computer to select the users but got nowhere with
(&(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType: 1.2.840.113556.1.4.804:=14))))(objectCategory=user)(cn=user1)))
(&(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType: 1.2.840.113556.1.4.804:=14))))(objectCategory=user)(cn=user2)))
etc
Thanks
Rezuma