Batch remove Users from Domain Groups not deleting user/group acco

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I work in a Highschool and at the end of each year I manually remove 20
students from each subject group in AD.
I have 280 groups, 20-30 students in each group (8400 approx entries to edit)
There must be a Batch file way of doing this?
I use batch files to put the kids in the correct subjects at the begining of
each year... but how can I easily create a list of all members in every group
that I can then maybe input into a batch file?
All my groups begin with "subj" and all users begin with "zz"

Hope someone can help
Thanks
Haydn
 
Haydn Gerken said:
I work in a Highschool and at the end of each year I manually remove 20
students from each subject group in AD.
I have 280 groups, 20-30 students in each group (8400 approx entries to
edit)
There must be a Batch file way of doing this?
I use batch files to put the kids in the correct subjects at the begining
of
each year... but how can I easily create a list of all members in every
group
that I can then maybe input into a batch file?
All my groups begin with "subj" and all users begin with "zz"

Nothing "hard" here, but it will (may) be tedious. You obviously
program a bit since you add users this way.

Have you looked at and used the ADSI script-o-matic?
Google this:

[ ADSI script-o-matic site:microsoft.com ]

Maybe the easiest is to just remove everyone (from these groups)
and then run the Add routing with all the correct members to add
them again....

Chances are it doesn't much matter how long this process takes
(within reason) since it only runs once per year/term.

If you take (as input) the administrative lists of Students-Courses
then you could just rebuild all needed groups each term.
 
I work in a Highschool and at the end of each year I manually remove 20
students from each subject group in AD.
I have 280 groups, 20-30 students in each group (8400 approx entries to edit)
There must be a Batch file way of doing this?
I use batch files to put the kids in the correct subjects at the begining of
each year... but how can I easily create a list of all members in every group
that I can then maybe input into a batch file?
All my groups begin with "subj" and all users begin with "zz"

Hope someone can help
Thanks
Haydn


From a Windows XP domain member, run the following:
NOTE: See tip 6820 » What are the new Active Directory command-line tools in Windows Server 2003?
in the 'Tips & Tricks' at http://www.jsifaq.com

@echo off
setlocal
for /f "Tokens=*" %%g in ('dsquery group -name subj*') do (
for /f "Tokens=*" %%u in ('dsget group %%g -members') do (
for /f "Tokens=* %%s in ('dsquery user %%u -o samid -name zz*') do (
dsmod group %%g -rmmbr %%u
)
)
)
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
Back
Top