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:

the-fastest-AD-Count-Check

Result:

the-fastest-AD-Query

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

Links :

Download AdFind (adfind.exe)
http://www.joeware.net/freetools/tools/adfind/

Download System.DirectoryServices.Protocols module (S.DS.P.psm1)
https://gallery.technet.microsoft.com/scriptcenter/Using-SystemDirectoryServic-0adf7ef5

Download QAD cmdlets (Get-QADUser)
http://software.dell.com/products/activeroles-server/powershell.aspx

All these tools in one file :
http://powershell-guru.com/tools/The-Fastest-Count-AD-Users.zip

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


next-button

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.

    Cheers!

    Reply
    1. powershellgu Post author

      Thanks for your comment, it’s always a pleasure to read some feedback.

      Be sure I will take in consideration your suggestion for a new article for the future, I really have a lot of subjects to talk in mind, in fact I just started recently the website and I am looking for the best way to organize me and manage the content.

      The idea behind this serie is to find the fastest way to perform a specific task. If someone have a faster solution, I will update my article, Powershell community is for me like a big family, everyone has something to bring (including beginners), and we are here to help each other and to share the knowledge.

      Steve

      Reply
  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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *