Extract First Name, Last Name and Email Address from Active Directory Using DSQuery

Sometimes an administrator needs to query Active Directory for specific information. In my case, I needed a way to extract the first name, last name and email address from all users in our domain. Thankfully, Microsoft offers a way to do this that is quite easy.

Just log into your Active Directory server, open a command prompt and paste the following:

dsquery user -limit 0 | dsget user -ln -fn -email >employee-list.txt

This will put all your information into a text file called employee-list.txt. You’ll find it waiting for you in “C:Documents and SettingsAdministrator“. Then just import the file into Excel and separate into columns using Fixed Width. Enjoy.