Archive for May 10th, 2007

What’s the most popular name in your company?

What’s the most popular first name in your organization? You could probably get some money by making bets. In a company as large and global as my employer (Quest) it is I don’t think many would be able to guess.

So how do you get the info? Going to HR is obviously not an option. The right option is using PowerShell and Active Directory cmdlets!

The first thing I did was the following:

  1. Use Get-QADUser to get all user accounts in my organization. I actually used -SizeLimit 100000 parameter so I get more than the default 1000: Get-QADUser -SizeLimit 100000
  2. Group them by first name and tell PowerShell to disregard the actual elements and only keep the statistics: Group-Object -Property FirstName -NoElement
  3. And finally sort them in descending order: Sort-Object Count -Descending.

Which gives the following one-liner:

PS C:\> Get-QADUser -SizeLimit 10000 | Group-Object -Property FirstName -NoElement | Sort-Object Count -Descending

This works with one gotcha. It turned out that there’s a huge percentage of service accounts and account for shared resources at Quest so the resulting list has a lot of false results. The top one was empty string – for all these accounts with no FirstName specified, the third – was a city name (it turned out that in one of our locations they used their city as the first name for all service accounts) and so on.

With the help of Andrei from AD cmdlets team I found a couple of workarounds (specific to Quest) that worked in making sure that only accounts for real human beings get into statistics. The workarounds are based on the fact that in our company all employees belong to one “Worldwide Everyone” group and have accounts in sub-OUs of one root OU created for users. Thus, instead of the oneliner used above these give more clean results:

Get-QADGroupMember "DN of the ubergroup" -SizeLimit 100000 | Group-Object -Property FirstName -NoElement | Sort-Object Count -Descending


Get-QADObject -ou "DN of the uber OU" -SizeLimit 100000 -asq member -scope base | Group-Object -Property FirstName -NoElement | Sort-Object Count -Descending

Have fun! And you don’t have to be a domain admin to run this!

P.S. At Quest the most popular name turned out to be Michael.

Tags: , , , , , , ,

My Recent Tweets


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

May 2007
« Apr   Jun »

%d bloggers like this: