Counting the Number of AD User Accounts in PowerShell

powershell cim 1 - Counting the Number of AD User Accounts in PowerShell

powershell cim 1 600x337 - Counting the Number of AD User Accounts in PowerShell

Here are some PowerShell examples that we can use to count the numbers of user accounts in Active Directory.

Total number of user accounts in AD

PS> (Get-ADUser -filter *).count

Total number of user accounts in an OU

PS> (Get-ADUser -filter * -searchbase "OU=Vancouver, OU=MyCompany, DC=Domain, DC=Local").count

Replace the SearchBase with your own OU path.

Total number of enabled/disabled accounts in AD

PS> (Get-AdUser -filter * |Where {$_.enabled -eq "True"}).count
PS> (Get-ADUser -filter * |Where {$_.enabled -ne "False"}).count

Total number of user accounts in a Group

PS> (Get-ADGroupMember -Identity "Group Name").count

PowerShell count AD User Accounts - Counting the Number of AD User Accounts in PowerShell

I ran these on a Windows 10 machine. If you get an error message saying the unrecognized command, follow this instruction to get PowerShell Active Directory Module installed.

5 thoughts on “Counting the Number of AD User Accounts in PowerShell

  1. hi,
    is that possible to count the aduser every 1000 objects and parse to csv file every completed 1000 objects and continue again after parsing to csv file?
    please advise on how to achieve and how to construct in powershell
    Thanks

Leave a Reply

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