Assuming you have a text file (e.g. C:\ADGroups.txt) containing multiple Active Directory (AD) Groups with one AD group per line, you may use an MS-DOS script similar to the following to create all those AD Groups in your Active Directory domain.

for /F "tokens=* delims= " %%G in (C:\ADGroups.txt) do (
 dsadd group CN="%%G",OU="Human Resources",OU="IT",DC=MYAD,DC=CYBERGAV,DC=IN
)

NOTE:
(1) If you are typing the script above at the MS-DOS command prompt, then replace %%G by %G.
(2) The “for” statement above, ensures that AD Groups containing blankspaces are read correctly.

VN:F [1.9.22_1171]
Rating: +6 (from 6 votes)

Tagged with:

Filed under: Windows

Like this post? Subscribe to my RSS feed and get loads more!