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

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:\FOLDER\AddDomGrpMbr.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, objGrp
set objArguments = Wscript.Arguments
if objArguments.count  2 Then
 Wscript.Echo "Syntax: Cscript //nologo c:\folder\AddDomGrpMbr.vbs ""GrpDn"" ""MbrDN"""
ELSE
grpdn = objArguments(0)
mbrdn = objArguments(1)
Const ADS_PROPERTY_APPEND = 3
Set objGrp = GetObject("LDAP://" & grpdn)
objGrp.PutEx ADS_PROPERTY_APPEND, "member", Array(mbrdn)
objGrp.SetInfo
END 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?


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