Please provide me with specific commands and parameters to accomplish what you're recommending.
Main Topics
Browse All TopicsGreetings -
Can anyone provide me with a simple way to count the number of users in an Active Directory group from the command line? All I want to know is how many *users* exist within an AD distribution or security group.
The result should not traverse nested groups and should count only user objects to eliminate groups as members of groups.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This can be performed using the AdFind utility available here:
http://www.joeware.net/fre
The syntax would be:
adfind -b "dc=domain,dc=com" -f (memberof="CN=Example Group DN,DC=domain,DC=com" -c
Output:
adfind -b "dc=domain,dc=com" -f (memberof="CN=Example Group DN,DC=domain,DC=com") -c
AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007
4 Objects returned
I love adfind... it was going to be my next choice but I thought I'd ask for syntax help here. :)
Your command works but I have a follow-up question, will this return only user objects that are members? Or all members? If possible, can it be restricted to return only user members? This eliminates counting subgroups as members.
Thank you!
Feel free to look at this other question while you're at it if you want more points... I'm sure adfind can do this too:
http://www.experts-exchang
Perfect!
Again, please look at my other question if you have the time, it would really save me a bunch of time today. Thanks again, great response.
http://www.experts-exchang
Business Accounts
Answer for Membership
by: askbPosted on 2009-10-19 at 09:46:32ID: 25606781
You could simply do a ldapsearch on the group / OU and count only the list of DN's.