Move Inactive Objects In Active Directory
Hello, you can use a single .bat file without problems. you can also use multiple .bat files. This posting is provided "AS IS" with no warranties or guarantees , and confers no rights. Microsoft Student Partner 2010 / 2011 Microsoft Certified Professional Microsoft Certified Systems Administrator: Security Microsoft Certified Systems Engineer: Security Microsoft Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration Microsoft Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration Microsoft Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuration Microsoft Certified Technology Specialist: Windows 7, Configuring Microsoft Certified IT Professional: Enterprise Administrator
June 5th, 2011 12:38pm

Hi All i have some commands to move and delete in Active users in AD i will make a .bat file and schedule task to run it my question is do i need to create more than one .bat file or a file for every command like file for move users and another one to delete users?Tarek Khairy
Free Windows Admin Tool Kit Click here and download it now
June 5th, 2011 3:05pm

If the commands you have run properly at a command prompt, they can be combined in one bat file. Each line of the bat file is executed in order, as if you entered them at a command prompt. I would only add that you cannot assume the current directory when a bat file is run as a scheduled task, so it is best to specify full paths. Also, if anything requires administrator privileges, like deleting or moving users, you must specify administrator privileges. Richard Mueller - MVP Directory Services
June 5th, 2011 6:59pm

You can use a single butt depends on the commands. Please the post the command here. Here is an example. You change replace DSQUERY Computer with DSQUERY User command: http://portal.sivarajan.com/2011/03/computer-cleanup-script-batch-file.html Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX Blogs - http://blogs.sivarajan.com/ Articles - http://www.sivarajan.com/publications.html Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara This posting is provided AS IS with no warranties,and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
June 5th, 2011 7:42pm

Thanks For your reply all my Commands as follow <!--[if gte mso 10]> <style></style> <![endif]-->for /f "Tokens=*" %%s in ('dsquery computer -inactive 13 -limit 1000') do ( DSMOVE %%s -newparent "OU=Computers,OU=Quarantine,OU=MyOu,DC=MyDomain,DC=local" ) <!--[if gte mso 10]> <style></style> <![endif]-->for /f "Tokens=*" %%s in ('dsquery user -inactive 13 -limit 1000') do ( DSMOVE %%s -newparent "OU=users,OU=Quarantine,OU=MyOu,DC=MyDomain,DC=local" ) dsrm -subtree -exclude -noprompt -c "OU=delete-user,DC=domain,DC=Com" Thanks Tarek Tarek Khairy
June 6th, 2011 1:23am

A possible issue I didn't think about was timing, where the results of the first command had not yet replicated to all other DC's, and the second command depended on the first, but contacted a DC where replication had not completed. However, there is no such timing issue possible with your commands. I see no problem combining the three statements in one batch. Richard Mueller - MVP Directory Services
Free Windows Admin Tool Kit Click here and download it now
June 6th, 2011 6:52am

thanks alotTarek Khairy
June 6th, 2011 6:58am

You are welcome! Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX Blogs - http://blogs.sivarajan.com/ Articles - http://www.sivarajan.com/publications.html Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara This posting is provided AS IS with no warranties,and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
June 6th, 2011 9:05pm

Hi in the command the limit refer to the number of users to be moved? ThanksTarek Khairy
June 7th, 2011 8:12am

The -Limit parameter is the maximum number of objects returned by the dsquery command. If no limit is provided, the limit is 100 DN's. More common is to use -Limit 0, which means no limit at all. Richard Mueller - MVP Directory Services
Free Windows Admin Tool Kit Click here and download it now
June 7th, 2011 9:53am

Hi Thanks for the reply i have another question can i exclude some users from this command because i have some generic users they never login to any system ? Thanks TarekTarek Khairy
June 8th, 2011 2:03am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics