Friday, December 13, 2024

New Groups in AD

Datamation content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Author: Eugenio Talarico
Platform: Windows

Type: VBScript

DESCRIPTION: You can use to create multiple groups into OU=GROUPS using this line in a batch file:


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 context of the input file is name_of_the_groups;comment

Scroll down to view the script.


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

Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided “as – is”, without any warranty, whether express or implied, of its accuracy,
completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you
may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Subscribe to Data Insider

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more.

Similar articles

Get the Free Newsletter!

Subscribe to Data Insider for top news, trends & analysis

Latest Articles