The fastest Powershell #1 : Count all users in Active Directory domain

By | February 10, 2015

Updated : October 01, 2015

Question : What is the fastest solution to count all the users in Active Directory domain?

Answer : To answer this question, I will compare 17 different commands in a domain with 75 000 users.

First, I check that all these commands return the same value:




Conclusion : In this scenario, the fastest was :
AdFind.exe -b 'DC=domain,DC=com' -f 'sAMAccountType=805306368' -c

Links :

Download AdFind (adfind.exe)

Download System.DirectoryServices.Protocols module (S.DS.P.psm1)

Download QAD cmdlets (Get-QADUser)

All these tools in one file :

Note : If you have a faster solution, feel free to comment below so I can update my article.


6 thoughts on “The fastest Powershell #1 : Count all users in Active Directory domain

  1. Pingback: # The fastest Powershell 2 : Read a text file

  2. ramblingcookiemonster

    Fun idea and nice presentation – looking forward to the rest of your series!

    Have you considered iterations and averaging out the results? One could imagine scenarios where environmental factors play a significant role in performance for a single iteration.


  3. Pingback: # The fastest Powershell 3 : Write to a text file

  4. Pingback: The fastest Powershell #2 : Count all files in a large network share | Powershell Guru

  5. Simon Winterborn

    You can probably improve the speed on most of these by querying for the ADsPath property rather then samAccountName, as ADsPath is included implicitly in the search results. Certainly for ADSISearcher, moving to ADsPath cut the time for a search of 140,000 users from 35 seconds to 18 seconds


Leave a Reply

Your email address will not be published.