Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to remove groups by groupType?

Status
Not open for further replies.

yellowartist

IS-IT--Management
Aug 5, 2007
19
0
0
US
What I am trying to occomplish is I have a script that generagtes a list of users that are tied to a specific global group. From that list I want to go through all the users and remove them from any Distribution Lists.

The group type is always Distributions list or 8

The Group Scope is universal on our Distribution lists.

I do not want to remove all the groups just the distribution lists.

I have tried this:

Code:
Set objUser = GetObject("LDAP://"& strdn)
objGroup.Remove "groupType", ADS_GROUP_TYPE_UNIVERSAL_GROUP
Wscript.Echo "Removed" & Strcn & "From DL's"

This of course did not work.

Code:
set objUser = GetObject ("LDAP://" & strdn)

Strdn = the distinguished name of the users.

I am guessing it has something to do with not binding to the group... It is making it through to the WScript.Echo
 
You are correct. What you need to do is the following.

Enumerate groups a user is a member of.
Bind to the group.
Check the group type.
Use If Then to see if it is the type you want to remove.
Delete the group.

Deleting a group is simple:

Set objOU = GetObject("LDAP://ou=hr,dc=fabrikam,dc=com")

objOU.Delete "group", "cn=atl-users"


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top