Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Wondering if someone could help me, i want to query active directory.

My aim is to produce a list of users and a total number of users, now our AD is full of meeting rooms, auto users, test users etc.

So i thought if add a word into these auto users descriptions i could write a script that excluded all users that have a "description = auto".

Only problem is im not the best programmer, any chance anyone could help me achieve this.

The reason for this i want to ensure we have the correct amount of CALs as CALs are not required for autp users only real people who access the system

Cheers for the help in advanced.

share|improve this question
What do you want to use to query AD? Script (which language)? dsa.msc? You may also want to consider creating/using groups for organizing these objects. – jscott Jan 10 '13 at 15:18
dsa.msc ideally, We do have groups sorted out i just wanted to create a script that i can run from my laptop if a auditor asks a question rather than me loggin into the server. – Brian Mitchell Jan 10 '13 at 15:19
up vote 3 down vote accepted

While you could certainly do this using a command line tool, you could also do this just as easily using ADUC by creating a Saved Query.


I missed the part where you wanted to set the description for all non human user accounts in order to filter your query for real users. That being said, you could still set the description en masse and perform a query for users not having that description in ADUC in about 90 seconds.

share|improve this answer
Thanks the query function works a charm. – Brian Mitchell Jan 10 '13 at 16:05
Glad to help... – joeqwerty Jan 10 '13 at 16:29

You can do this pretty easily in powershell doing something like

import-module activedirectory
get-aduser -filter {-not (description -eq "auto")} | measure-object
share|improve this answer
This is very usefull, thank you – Brian Mitchell Jan 10 '13 at 16:06

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.