skip to Main Content

Get Active Directory count with PowerShell

How to count Active Directory objects, and why do we need the AD objects count? In our example, we want to have the total count before we install and configure Azure AD Connect. That’s because we need to know the total AD objects for the minimum server requirements. In this article, we will look at how to count AD objects with PowerShell.

Count AD users

Count AD users with PowerShell. Use the Get-AdUser cmdlet.

PS C:\> (Get-AdUser -Filter *).Count

Count AD groups

Count AD groups with PowerShell. Use the Get-ADGroup cmdlet.

PS C:\> (Get-ADGroup -Filter *).Count

Count AD computers

Count AD computers with PowerShell. Use the Get-ADComputer cmdlet.

PS C:\> (Get-ADComputer -Filter *).Count

Get AD total count

Let’s add the user, group, and computer counts together with PowerShell. Use the below script, copy and paste it in PowerShell ISE. You can also download Get-ADCount.ps1 script and run it from PowerShell.

$ADUser = (Get-AdUser -Filter *).Count
$ADGroup = (Get-ADGroup -Filter *).Count
$ADComputer = (Get-ADComputer -Filter *).Count
$ADObjects = $ADUser + $ADGroup + $ADComputer

This is how it looks after you run the script. The total AD objects are 4484.

PS C:\> $ADUser = (Get-AdUser -Filter *).Count
$ADGroup = (Get-ADGroup -Filter *).Count
$ADComputer = (Get-ADComputer -Filter *).Count
$ADObjects = $ADUser + $ADGroup + $ADComputer

That’s it! Did it help you to retrieve the total AD objects count?

Read more: Get total user count in Exchange »


In this article, you learned how to get Active Directory count with PowerShell. Count AD objects before you start deploying an application that makes use of the AD objects.

Did you enjoy this article? You may also like Count health mailboxes in Exchange. Don’t forget to follow us and share this article.



ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

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