Q. How can I use a VBScript to add a global security group to my domain?

Jerold Schulman

July 20, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

I have scripted AddDomGrp.vbs to add a global security group to a domain.

The syntax for using AddDomGrp.vbs is:

cscript //nologo c:FOLDERAddDomGrp.vbs GroupCN, OU_or_Container, sAMAccountName

Where:

GroupCN         is the Canonical Name of the group, like "CN=Domain Users".OU_or_Container is container or organizational unit of the new group, like "CN=Users,DC=JSIINC,DC=COM"                or "OU=East Coast,DC=JSIINC,DC=COM"sAMAccountName  is Pre-Windows 2000 account name, like "Users".

AddDomGrp.vbs contains:

dim  objArgumentsset objArguments = Wscript.Argumentsif objArguments.count  3 Then Wscript.Echo "Syntax: Cscript //nologo c:folderAddDomGrp.vbs ""GrpCn"" ""OUorCont"" ""sAMAccountName"""ELSEgrpcn = objArguments(0)OUorCont = objArguments(1)sAMAccountName = objArguments(2)Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000Set objOU = GetObject("LDAP://" & OUorCont)Set objGroup = objOU.Create("Group", grpcn)objGroup.Put "sAMAccountName", sAMAccountNameobjGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _    ADS_GROUP_TYPE_SECURITY_ENABLEDobjGroup.SetInfoEND IF 

NOTE: See the following related scripts:

How can I use a VBScript to add a member to a group in my domain?How can I use a VBScript to remove a member from a group in my domain?


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like