KB ID 0001748
I had to get some stats from a number of customers earlier today, one of the stats I needed was the user count from within their respective Active Directories. If you have a tedious job to do, there’s usually a PowerShell command to help!
Getting Object Numbers From Active Directory
(Get-ADUser -Filter *).Count
(Get-ADComputer -Filter *).Count
(Get-ADGroup -Filter *).Count
Enabled or Disabled User Count
That’s all fine, but what if you needed to only see enabled or disabled users?
(Get-AdUser -filter ‘Enabled -eq $true’).count (Get-AdUser -filter ‘Enabled -eq $false’).count
Group User Count
Or only users in a particular group?
(Get-ADGroup GS-VPN-Users -Properties *).Member.Count
OU User Count
Or only users in a particular OU?
(Get-ADUser -Filter * -SearchBase “OU=Users, OU=PNL,DC=pnl,DC=com”).Count
Related Articles, References, Credits, or External Links