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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enumerate groups

Status
Not open for further replies.

terry712

Technical User
Oct 1, 2002
2,175
GB
does anyone have a script that does the following

basically i want to have a dynamic security group - so basically have a group called say site1-gls

and i want this to be created from 3 or 4 other gls groups. i know this will need to be on a sched task or such like - but basiacally what it to add and delete mebers as it goes

it may be a case or easier if the site1-gls group membership is deleted and repopulated rtaher than try the delete
 
I don't have code like this. Someone may. Assuming that no one comes along that does, this shouldn't be terribly hard to do. You really only need to know how to do three things. Read the members of a group, add members to a group, and remove members from a group (or remove all members if you want to go that route). All the rest is logic. So basicly pick one of those actions and figure out how to do it. Then the next, then the last. Then just put the three parts together.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
was just seeing if someone has a script
before i satrt trying to rattle one together

 
Yes, I have such a script.

You process is to first bind to each group.

Make the members of the dynamic group keys in a dictionary for easy checking.

Enumerate the members of the other groups into an array. Then iterate through the array checking for if a matching key exists in the dictionary. If it does not then add the group member. Don't wipe out the former membership unless you are certain the update will happen when no users are logged on, otherwise existing users will lose the membership until next logon.

If you want to dynamically remove users as well then reverse the process. Add the members of the source groups to a dictionary. Then for each member of the dynamic group check for a matching key and if none exists remove the user from the group.

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