Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use Get-AQDUser to get a summed list of users per country. So far a have this

$Country = Read-Host "Please Enter the country of which you want to see users "
Get-QADUser -ObjectAttributes @{co="$Country"} | ft displayname, co -auto

and this lists the user names perfectly, but not summed. To get them summed i added the following to above

| Measure-Object

This gives me the number of users, but it counts 4 more users than there is. If I search for users in ADUC, it gives me the correct number. I also tried with the .Count parameter, but this also gives me 4 more users, than there actually are. And i am searching from the root of our AD.

Any idea, why |measure-object always gives me 4 users too many?

share|improve this question
Make sure to accept the answer when its a good one ;-) Keeps the community in good holiday spirits!! – Mike Dec 7 '12 at 20:16

Measure-Object measures whatever is piped into it, in your case, the output of Format-Table. This means Measure-Object will measure the table, including the headers, separators, etc., as well as the values.


Get-ADUser jscott | Measure-Object
Count    : 1

Get-ADUser jscott | Format-Table | Measure-Object
Count    : 5

Exactly four extra. You should probably just skip the Format-Table until you want to display the output values on-screen, after you've counted them. Using your example, the following should return the correct number of users:

Get-QADUser -ObjectAttributes @{co="$Country"} | Measure-Object
share|improve this answer
Wow, that simple, never thought of trying that. Thanks a bunch – Jens Svendsen Dec 7 '12 at 8:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.