Solved

how to get AD group member count for a group with more then 5000 users

Posted on 2014-04-28
4
5,425 Views
Last Modified: 2014-04-28
Hi EE

I need to get the count for users in certain AD groups that have more then 10k users and neither of these options allow me to get the count . I don't want to modify the DC settings to expand the 5000 threshold  .  Does anyone have a work around for this ?

both of these fail .

Get-ADGroupMember "Test_Group" | Measure-Object | select count

If ([array]$users = (Get-ADGroupmember -Identity "Test_Group")) {
"Number of users in group: $($users.count)"
}
0
Comment
Question by:MilesLogan
  • 2
4 Comments
 
LVL 15

Expert Comment

by:WalkaboutTigger
ID: 40028576
Try this:

$members = Get-QADGroupMember -SizeLimit 0 'domain users' -ldap "(&(!userAccountControl:1.2.840.113556.1.4.803:=2))"
@($members).count

This does require the Quest PowerGUI from Dell, which can be found at

http://www.quest.com/powergui-freeware/
0
 
LVL 15

Accepted Solution

by:
WalkaboutTigger earned 250 total points
ID: 40028579
If you want to use native code, try

$group =[adsi]”LDAP://CN=Groupname,CN=Users,DC=domain,DC=local” 
$members = $group.psbase.invoke("Members") | foreach {$_.GetType().InvokeMember("name",'GetProperty',$null,$_,$null)} 
$members.count

Open in new window

0
 
LVL 39

Assisted Solution

by:footech
footech earned 250 total points
ID: 40028624
Here's another script bit using the adsisearcher type accelerator.  Just put in the name of your group instead of "some group" (can also use wildcards).  One note - it won't list members of the group that have that group set as the account's primary group.  If you never change this from "Domain Users" then it's not a problem.
([ADSISearcher]"(&(ObjectClass=group)(name=some group))").FindAll() | % {$_.properties.member}

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 40028742
Thank you both !! EE Rocks !
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now