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

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

The syntax for using AddDomGrp.vbs is:

cscript //nologo c:\FOLDER\AddDomGrp.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  objArguments
set objArguments = Wscript.Arguments
if objArguments.count  3 Then
 Wscript.Echo "Syntax: Cscript //nologo c:\folder\AddDomGrp.vbs ""GrpCn"" ""OUorCont"" ""sAMAccountName"""
ELSE
grpcn = objArguments(0)
OUorCont = objArguments(1)
sAMAccountName = objArguments(2)
Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000
Set objOU = GetObject("LDAP://" & OUorCont)
Set objGroup = objOU.Create("Group", grpcn)
objGroup.Put "sAMAccountName", sAMAccountName
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _
    ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo
END 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?


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish