DSQUERY- Need to pull email IDS from AD

amku03
amku03 used Ask the Experts™
on
Hi,

I have a csv file with user first name, last name and logon name.
ineed to pull their email ids and update the file.
please suggest ....how to do this with dsquery dsget?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In the csv file copy the user logon name column to a new text file. Save it as whatever you like. Then run the following bat below.
for /F "tokens=1" %%h IN (filename.txt) Do dsquery user -samid "%%h" |dsget user -ln -fn -email -samid
pause

Open in new window

Actually you will need to redirect it to an output file so the code should be.  Since this loops you will need to clean the headings off of the finished output.
for /F "tokens=1" %%h IN (filename.txt) Do dsquery user -samid "%%h" |dsget user -ln -fn -email -samid >> c:\somefile.txt
pause

Open in new window

Commented:
Please check link, might help you.

http://www.manageengine.com/products/ad-manager/

Author

Commented:
Thanks for your time!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial