Someone who read my recent post about domain statistics asked whether it was possible to get not just the number and list of, say, departments (or locations, or pick-your-favourite-attribute) but also the number of users belonging to each of them. And the answer is – easy!
All you need is: get all your user accounts and group them by the attribute you need! You can then optionally sort them by the number of users inside, and choose whether or not you want to see a sample of the users.
So basically if you just need a list of departments with their statistics you just run:
PS C:> Get-QADUser | Group-Object -Property Department -NoElement
Count Name
----- ----
441 Administration
271 Development
91 Marketing
197 Sales
Sorted by the number of users inside:
PS C:> Get-QADUser | Group-Object -Property Department -NoElement | Sort-Object Count -Descending
Count Name
----- ----
441 Administration
271 Development
197 Sales
91 Marketing
With a sample of users inside:
PS C:> Get-QADUser | Group-Object -Property Department
Count Name Group
----- ---- -----
441 Administration {Administrator, Guest, krbtgt, IUSR_SPB9880...}
271 Development {SUPPORT_388945a0, user_name_5, user_name_15, user_name_25...}
91 Marketing {user_name_4, user_name_40, user_name_41, user_name_42...}
197 Sales {user_name_23, user_name_30, user_name_31, user_name_32...}
And if you need statistics by City or any other attribute – just substitute Department
with City
or that attribute name. It’s as easy as it gets!
0 Responses to “Domain Statistics with PowerShell continued”