• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

need assistance with new group creation script

Can someone assist me with the following script. The purpose of the script is to create multiple groups in Active Directory using a .txt input file.
It is not working.
here is the bat file that i use to run the VBS script:

for /F "tokens=1-2 usebackq delims=;" %%1 in (input.txt) do ( cscript NewGroups.vbs %%1 %%2 //B //Nologo >> err_log.txt 2>>&1 )

the "input.txt" file would contain the names of the groups i want to create. I've attached the VBS code below:
Please let me know what i need to change to make this script work.

thx in advance!

Mike
''****************************************************************************
''*
''* 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

Open in new window

0
siber1
Asked:
siber1
1 Solution
 
yehudahaCommented:
hey

my script read list from this path you can change the name and path to what ever you want

Set objlist = objfso.OpenTextFile("c:\list.txt", ForReading)

the txt file need to be

group1 name;group1 description
group2 name;group2 description

you need to set ou here:
strOu = "ou=UsersContainer"
Const ForReading = 1
  
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objlist = objfso.OpenTextFile("c:\list.txt", ForReading)
 
strOu = "ou=UsersContainer"
 
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = strContainer & "," & objRootDSE.Get("defaultNamingContext")
 
Do Until objlist.AtEndOfStream
strTemp = Split(objlist.ReadLine,";")
strGroup = strTemp(0)
strDesc = strTemp(1)
Set objOU = GetObject("LDAP://" & strOu & strDomain)
Set objGroup = objOU.Create("Group", "cn=" & strGroup)
objGroup.Put "sAMAccountName", strGroup
ObjGroup.Put "Description", strDesc
objGroup.SetInfo
Loop

Open in new window

0
 
siber1Author Commented:
thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now