Background: The Active Directory Users & Computers (ADUC) UI lets you list the mail column for each object, which displays the default (SMTP) email address for objects. You can export the list from ADUC to a CSV/txt file. However, any additional email addresses in the proxyAddresses attribute are not exported.
There’s no GUI interface (in ADUC or ESM) to list or export all email addresses. Here’s a script to do that – ListEmailAddresses.vbs.
File: ListEmailAddresses.zip
Download link updated to non-HTTPS.
What does it exactly do?
- Queries Active Directory for Contacts & Groups
- Lists their email addresses
- Queries Users
- Lists enabled users’ email addresses
- Lists disabled users’ email addresses separately (was required for a certain project I did a long time back)
- Outputs to command line and also to a text file – c:\proxyaddresses.txt
– X.400 addresses are ignored
Hi All,
I have an exchange question, but is unrelated to this specific topic. I was wondering if anyone here could assist or suggest a good place where I could get some assistance.
A friend of mine has a Small Business Server 2003 machine that he was using for several years for his business. He has since closed the business and set aside his machine. Now he needs to get his emails from his account off his old server.
How can he export his old emails from the database on the exchange server 2003 to something (I guess a .pst file), that he can import into his current outlook program, which seems to only have some of his latest emails, and not all of them from the previous set of years. As far as I know since the company was fairly small, there was never any archived and removed emails., They should all be there.
Thank you in advance for your consideration and support.
I can be reached at KShapiro-at-Bigfoot-dot-com. (Obviously replace the “-at-” with “@”, and “-dot-” with “.”
Sincerely,
Kevin Shapiro
Thank you, very helpful :)
Dood.. You rock, you just saved me hours worth of work. Much appreciated.
I also get the (54, 13) (null): 0x80005000 error.
This is from running the script as is without changing any of the contents.
I know what my distinguished name is. Do I have to change the code in some way by physically inserting the distinguished name somewhere so it wull run?
Any help to get this running so I can impress my boss greatly appreciated!
Thanks for the script, but I’m getting the error: C:\ListEmailAddresses.vbs(52, 13) ADODB.Recordset: Item cannot be found in the collection
corresponding to the requested name or ordinal.
I’ve adjusted / entered my distinguishedName.
Any help would be appreciated!
Thanks,
Tom
I’ve got the same message
Item cannot be found in the collection
corresponding to the requested name or ordinal.
Please help
What needs modified in this script to allow it to capture this data? I am new to scripting…
PERFECT!
Shows the primary smtp address and all other smtp addresses (aliases) in the domain on a per user basis
Thanks a lot!
(for above, usage:
– Unzip and enter this in command prompt:
cscript C:\ListEmailAddresses\ListEmailAddresses.vbs > c:\bla.txt)
This script is great, particularly usefull if you need to set up mail archiving solutions on a well established domain. Many thanks, Carlton, UK
Thanks a tonne. You’ve really helped me out. :-)
Hi,
Great script, but I too am getting this error:
"error: ADODB.Recordset: Item cannot be found in the collection
corresponding to the requested name or ordinal."
The path in AD I wish to output is:
nonprofit.lib.mo.us > Microsoft Exchange Security Groups > Employee Exchange group
I have modded the "distinguishedname" as follows:
strUserDN = objRecordSet.Fields("OU=Employee Exchange group,OU=Microsoft Exchange Security Groups,DC=NONPROFIT,DC=LIB,DC=MO,DC=US") 'Get User's distinguished name from Recordset into a string
set objUser= GetObject("LDAP://"& strUserDN & "")
What have I done wrong?
Thanks
Wonderful script, thank you very much. Appreciate it.
Thank, works great !
This script worked great for most server. I noticed that if I had an OU called the same as the domain I got ListEmailAddresses.vbs(100, 13) (null): 0x80005000 error.
Just did not get it to work on that OU.
How’s it going with also listing the e-mail addresses of the Public Folders? :)
@Anonymous: Haven’t had the time to pick up the Public Folders part yet…
I’m scratching my head as I think about VBScript again (given how easy this is using Exchange shell/Powershell in Exchange 2007)… :)
Brilliant idea, wonderful script. MS should learn from you.
Thanks
Excellent tool, ran on test environment (few users) worked perfectly. But on production where I have alot more users i get the ListEmailAddresses.vbs(55, 13) (null): 0x80005000, even with the following objCommand.Properties(“Page Size”) = 5000
any advice what i need to do ?
Awesome, thanks for this script it has saved me from a big headache, and hours of tedious work.
—Feels like Home—
Great script! Works like a charm.
Thanks for sharing
To fix the (null): 0x80005000 error, you have to insert the following line in 2 places:
strUserDN = Replace(strUserDN, “/”, “\/”)
You have to add it after line 53 and the other line that says: strUserDN = objRecordSet.Fields(“distinguishedName”)
You have to do this because some domains (like mine) have global groups with the / characters in them and that will cause the query to fail.
Check out this article for the explaination:
http://www.tek-tips.com/viewthread.cfm?qid=775481
Enjoy
Thanks so much! Saved me hours.
I’m sorry, I’m still back with Stewart on 4/7/2008.
Are we supposed to edit the script to define our specific
“distinguishedName”? And if so, where and how?
@Another David: The script picks up your AD path by querying AD for RootDSE. You generally don’t need to edit anything to run it.
See Serverless Binding and RootDSE for more info.
Thanks you very much… great script. I also modified it to
pull all public folders proxy address….
bravo! thx for sharing this tool, it fixed all my headache!
This works perfectly. I wonder why there is no such function accessible via GUI in Exchange Server. Thanks a lot!
thank you very much!!!!!!!!
I've been using cygwin with adfind for a while now, and it's easy to come up with commands to assist with AD management.
To get all the email addresses from a domain:
adfind -default -f "(objectcategory=user)" mail | grep @ | sed -e 's/>mail: //g' | sort
You could also output the results to a file.
There probably is an easier way with adfind to do that, but this has worked for me.
Adfind is a great tool.
But for the same funcionality of vbscript, try this:
adfind -default -f "(objectcategory=user)" proxyAddresses | grep @ | sed -e 's/>mail: //g' | sort
Great script worked a treat! many thanks
Hi,
Really like the script. thanks!!!
But how do I add the user’s loginname to this???
Kind regards,
M
Brilliant.
Thanks very much.
Hello,
Exchange 2007 :
Is there a way to show E-mail adresses (SMTP / proxy )in all public folders, even Hidden ?
And where I can find the Folder.
No Succes with : Get-MailPublicFolder | select Name,EmailAddresses
Thanks,
Great script thanks a lot.
Sweet, thanks for sharing this script!
For marketing purposes I'd like to crawl through the exchange server and get all *external* email addresses that our local users are sending / reciving from. If I had those in a CSV, I could write a vba routine to weed out the valid marketing contact. How do I do this?
@Michael: This info can be found in message tracking logs.
gr8 script ….. thanks much for your time and supports..keep going guys… realyy doing great help!!!!!!!!!!!!!!!!!!!!
really great script! you helped me a lot.
Thought you should know, your script is still coming in very handy. Thank you. It worked beautifully.
— Campbell
@Campbell: Thanks! This was one of my favorites when I wrote it a few years ago.
well, never work for me
Thanks a bunch, it still works perfectly
Jan
Great script. Ran perfectly first time. Great output. Thanks for putting this out there.
Excellent script, thank you for your efforts!
Excellent – thanks for the script – I kept getting error messages too until I edited the script as the anonymous poster noted on 12-3-08 9:21P
to insert the line strUserDN=Replace(strUserDN,"/","\/") after line 53 and the other line that says strUserDN=objRecordSet.Fields ("distinguishedName")
Then your script worked like a charm.
It took me the better part of a day to figure out after reading all these posts and trying a bunch of stuff – I'm not a scripting expert so it probably took me a little longer than the average scripter
Thanks again
Thanks for the script. It works great. The only problem I had was the same Line 54 char 13 I see other people having… and the ADODB.Recordset error.
I inserted the string strUserDN = Replace(struserDN,"/","\/") after line 53 and after the line that says strUserDN=objRecordSet.Fields("distinguishedName")
Thanks for the script. It took me a little longer to diagnose and fix the errors than the average scripter – because I am not as experienced with scripting.
Thanks for the script.
@Battman: Thanks for the update!
Great work. You have saved me a lot of time and effort