Use this:
This script is composed by 3 file
1 input.txt the input file is used to retrieve the object name
2 the batch used to "run" the vbs and take the information from the txt
3 the VBS file NewGroups.vbs
The file BAT create a series of groups from
the file input.txt. (use " " for the name of the groups)
The groups will be created BY DEFAULT into OU=GROUPS
if you specify inside the .vbs file the path where you
want to create groups it will works for every OU.
'****************************************************************************
'* THe sintax you have to use to run the script is
'* cscript newgroups.vbs NAME_OF_THE_GROUPS
'* Name_of_the_groups rappresent the groups you need to create
'*****************************************************************************
'*****************************************************************************
'* INTO STRVARIABL LINE PUT THE PATH WHERE THE GROUPS
'* WILL CREATED (EX: strVariabl = ",OU=Standard Users,OU=DomainNAME,")
'*****************************************************************************
'*****************************************************************************
strVariabl = "OU=groups"
'*****************************************************************************
'*****************************************************************************
'*****************************************************************************
That's all.
Script by: Eugenio Talarico
mailto: eugeniot @ _R_E_M_O_V_E___ larico.it
so here the structure:
1 input.txt
GROUPS_NAME;Comment
2 BATCH FILE
@echo on
echo ****************************************
Echo * script for multiple groups creation *
echo ****************************************
for /F "tokens=1-2 usebackq delims=;" %%1 in (input.txt) do (
cscript NewGroups.vbs %%1 %%2 //B //Nologo >> err_log.txt 2>>&1 )
3 VBS FILE NewGroups.vbs
'****************************************************************************
'*
'* Create a new groups IN an ACtive Directory Infrastructure
'*
'* Created By Eugenio Talarico - 10/12/2003
'*
'****************************************************************************
'* THe sintax you have to use to run the script is
'* cscript newgroups.vbs NAME_OF_THE_GROUPS
'* Name_of_the_groups rappresent the groups you need to create
'*****************************************************************************
'*****************************************************************************
'* INTO STRVARIABL LINE PUT THE PATH WHERE THE GROUPS
'* WILL CREATED (EX: strVariabl = ",OU=Standard Users,OU=DomainNAME,")
'*****************************************************************************
'*****************************************************************************
strVariabl = "OU=groups"
'*****************************************************************************
'*****************************************************************************
'*****************************************************************************
'**Start Encode**
dim nome
dim Commento
ParseCommandLine()
wscript.echo nome
Const ADS_PROPERTY_APPEND = 3
Set objRootDSE = GetObject("LDAP://rootDSE")
strFissa = strVariabl & "," & objRootDSE.Get("defaultNamingContext")
wscript.echo strFissa
Set objGroup = GetObject _
("LDAP://"& strFissa)
Set objGroup = objGroup.Create ("group", "CN=" & nome)
objGroup.Put "sAMAccountName", nome
ObjGroup.Put "Description", commento
objGroup.SetInfo
Sub ParseCommandLine()
Dim vArgs
set vArgs = WScript.Arguments
if vArgs.Count <> 2 then
DisplayUsage()
Else
nome = vArgs(0)
commento = vArgs(1)
End if
End Sub
>> Stay informed about: Creating groups in child OUs