Using the DSQUERY utility to print a system generated list of Active Directory users

DSQUERY is a command line tool that comes with Windows 2003 server. This utility can be run locally or copied off to a domain joined XP workstation for use. To generate a list of users from Active Directory, navigate to the utility’s directory via command prompt.

Use the folowing example to dump a list of all accounts to a .txt file named netusers at the root of the C drive.

dsquery user -o rdn -limit 500 >C:\netusers.txt

The -o rdn parmeter will output users’ full names. The default value is dn – distinguished name. Another option is to output the list as upn, user principle name. The -limit 500 option overrides the default 100 item return baked into the program, use a reasonable high value to ascertian you catch all the accounts in AD.

More options can be listed using the DSQUERY /HELP command.