Domain Statistics with PowerShell continued

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!

Advertisement

0 Responses to “Domain Statistics with PowerShell continued”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

April 2007
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  

%d bloggers like this: