Q. How can I use a VBScript to add a member to a group in my domain?

Jerold Schulman

July 20, 2006

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

I have scripted AddDomGrpMbr.vbs to add a member to a group in a domain.

The syntax for using AddDomGrpMbr.vbs is:

cscript //nologo c:FOLDERAddDomGrpMbr.vbs GroupDn, MemberDN

Where:

GroupDN  is the Distinguished Name of the group, like "CN=Domain Accountants,CN=Users,DC=JSIINC,DC=COM".MemberDN is the Distinguished Name of the member you wish to add, like "CN=John Doe,CN=Users,DC=JSIINC,DC=COM".

AddDomGrpMbr.vbs contains:

dim  objArguments, objGrpset objArguments = Wscript.Argumentsif objArguments.count  2 Then Wscript.Echo "Syntax: Cscript //nologo c:folderAddDomGrpMbr.vbs ""GrpDn"" ""MbrDN"""ELSEgrpdn = objArguments(0)mbrdn = objArguments(1)Const ADS_PROPERTY_APPEND = 3Set objGrp = GetObject("LDAP://" & grpdn)objGrp.PutEx ADS_PROPERTY_APPEND, "member", Array(mbrdn)objGrp.SetInfoEND IF

NOTE: See the following related scripts:

How can I use a VBScript to add a global security group to 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