Solved

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

Posted on 2014-04-28
4
5,361 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you both !! EE Rocks !
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
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…
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 to another domain controller. Log onto the new domain controller with a user account t…

772 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