We help IT Professionals succeed at work.

Need help creating query for all mail users in our domain

I have a department that needs an Excel spreadsheet of all users with a mailbox in our domain.  preferably Full name (account name/logon name won't help them) and exchange mail address. i need either a query in AD Users and Computers with instructions how (to include how to put in excel) or a command line query exporting to excel.  i do not know/use Powershell, so i would need this in the form of a dsquery, dsget, etc so i can run it off of my command line.  i tried a query but it ran/hung for over a day so i'm assuming something was wrong.  we have about 2000 users in our Exchange 2003 domain.  thanks.
Comment
Watch Question

dsquery.exe * -filter "(&(objectClass=user)(!(objectClass=computer)(sAMAccountName=username)))" | dsget user -email -samid -display

See if this helps.

Regards,
Exchange_Geek

Author

Commented:
thanks for the prompt response.  i copied/pasted the command from your entry to ensure the syntax is correct and got the following:

dsget failed:`Target object for this command' is missing.
type dsget /? for help.

whatcha think?
My bad this wont get the data from entire AD

Use the following.

csvde -r "(&(objectClass=*)(proxyaddresses=*))" -l displayname,proxyaddresses -f Data.csv

Regards,
Exchange_Geek

Author

Commented:
i'm sorry.  i did the first query from my computer and it didn't run, however it ran from my DC.  the second (csvde) gave me MUCH more info than i need in the form of CNs, distro groups, etc. that is not really usable for who it's goin to without going 1 by 1 through the list to remove invalid entries...

can you please relook the first one with dsquery, i got:

Williamsp      Cn=Williams\\..., WIlliams,Perry, Ou=Creation,Dc=xxx,Dc=xxx,Dc=xxx      Williams, Perry      Williams      Perry      Communications Specialist - 950344

which is PERFECT, but it only gave me 800+ users in the domain when i know i have 2000+.  know what we may need to change to get it to show all users in the domain?
csvde -r "(&(objectClass=user)(proxyaddresses=*))" -l displayname,proxyaddresses -f Data.csv

Try this meanwhile I am looking into dsquery cmdlet

Regards,
Exchange_Geek

Author

Commented:
thank you so much.
Did csvde help?

Regards,
Exchange_Geek

Author

Commented:
helper was responsive and provided a good result.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.