In Exchange Server, we can load Exchange Management Shell module in Windows PowerShell ISE. This…
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
3210
Count AD groups
Count AD groups with PowerShell. Use the Get-ADGroup cmdlet.
PS C:\> (Get-ADGroup -Filter *).Count
244
Count AD computers
Count AD computers with PowerShell. Use the Get-ADComputer cmdlet.
PS C:\> (Get-ADComputer -Filter *).Count
1030
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
$ADObjects
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
$ADObjects
4484
That’s it! Did it help you to retrieve the total AD objects count?
Read more: Get total user count in Exchange »
Conclusion
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.
This Post Has 0 Comments