How to delete all members in an AD group from command line?

  • Thread starter Thread starter Swanny
  • Start date Start date
S

Swanny

I want to delete all the members of an AD global security group from
the command line. Is there an easy way to do this?

What I'm doing is deleting everyone in the group (~3,000 members) and
will re-populate it using the "net group GROUPNAME /add USERNAME
/domain" syntax. I tried running "net group GROUPNAME /delete /domain"
but that deleted the whole group (whoops).

Thanks.
 
I want to delete all the members of an AD global security group from
the command line. Is there an easy way to do this?

What I'm doing is deleting everyone in the group (~3,000 members) and
will re-populate it using the "net group GROUPNAME /add USERNAME
/domain" syntax. I tried running "net group GROUPNAME /delete /domain"
but that deleted the whole group (whoops).

Thanks.
Hi Swanny,
This looks like the solution to your problem ;) :

Removing All the Members of a Group
http://www.microsoft.com/technet/community/scriptcenter/user/scrug189.ms
px

For your convenience, here's the script from the above link:

Const ADS_PROPERTY_CLEAR = 1

Set objGroup = GetObject _
("LDAP://cn=Sea-Users,cn=Users,dc=NA,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_CLEAR, "member", 0

objGroup.SetInfo


Also, as an alternative to 'net group' you can consider this script:

Adding New Members to a Group
http://www.microsoft.com/technet/community/scriptcenter/user/scrug188.ms
px

HTH
--
Cheers,
Marin Marinov
MCT, MCSE 2003/2000/NT4.0,
MCSE:Security 2003/2000, MCP+I
-
This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Thanks, but those links don't work for me. Do they work for you?
Perhaps they're out-dated.

Swanny

....> Removing All the Members of a Group
....> Adding New Members to a Group
 
You lost "px" off the end of the URL. Probably it wrapped. The last
bit is "scrug188.mspx".

Cheers,

Cliff
 
Back
Top