Skip navigation

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

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

The syntax for using DelDomGrpMbr.vbs is:

cscript //nologo c:\FOLDER\DelDomGrpMbr.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 remove, like "CN=John Doe,CN=Users,DC=JSIINC,DC=COM".
DelDomGrpMbr.vbs contains:
dim  objArguments, objGrp
set objArguments = Wscript.Arguments
if objArguments.count  2 Then
 Wscript.Echo "Syntax: Cscript //nologo c:\folder\DelDomGrpMbr.vbs ""GrpDn"" ""MbrDN"""
ELSE
grpdn = objArguments(0)
mbrdn = objArguments(1)
Const ADS_PROPERTY_DELETE = 4
Set objGrp = GetObject("LDAP://" & grpdn)
objGrp.PutEx ADS_PROPERTY_DELETE, "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 add a member to 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