Creating AD groups with a batch file

Posted by Dark Training on July 9, 2012 tags: | windows | batch

If you have ever had to create a bunch of AD groups and the thought of having to do it manually was going to make your fingers jump off your hands, I've got a script for you.

FOR /F "tokens=1* delims=" %%A IN (C:\list.txt) DO (
 dsadd group CN=%%A,OU=group,DC=your,DC=tld,DC=domain
)

In this example I created text file in C:\ call "list.txt" with the names of the groups that I wanted to make, then I simply create a batch (.bat) script with the code above and it will loop over each line, making the group in the default container.

Hope this helps, if so leave a note below and let others know!