We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Export complete list of SMTP addresses

MCPJoe
MCPJoe asked
on
Medium Priority
1,231 Views
Last Modified: 2010-05-18
I need to export from AD or Exchange a complete list of SMTP addresses.  This includes all SMTP addresses, not just the primary.  Some my my users and DL's have more than one SMTP address.  I'm having trouble getting the saved queries or even adding the e-mail address column to ADUC.  Any suggestions or tips?

Thanks
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Hi MCPJoe,

Do this in command prompt.

dsquery user | dsget user -email


Cheers!
CERTIFIED EXPERT
Commented:
Hi MCPJoe,

I have used this script with major success (it will get ALL smtp addresses (up to 20))

http://www.visualbasicscript.com/m_29830/tm.htm

Hope that helps,

-red

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
All I get are 100 default entries in the output, what syntax do I use the -limit argument to get all my records?
CERTIFIED EXPERT
Commented:
'Global variables
Dim Container
Dim OutPutFile
Dim FileSystem

'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("smtpaddresses.txt", True)

'Replace with valid DN of the container you want to enumerate
Set Container=GetObject("LDAP://DC=domain,DC=local")

'Enumerate Container
EnumerateUsers Container

'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set Container = Nothing

'Say Finished when your done
WScript.Echo "Finished"
WScript.Quit(0)

'List all Users
Sub EnumerateUsers(Cont)
Dim User

'Go through all Users and select them
For Each User In Cont
Select Case LCase(User.Class)

'If you find Users
Case "user"
  'Select all proxyAddresses
  Dim Alias
  If Not IsEmpty(User.proxyAddresses) Then
    'OutPutFile.Write User.DisplayName
    For Each Alias in User.proxyAddresses
        If InStr(1,Alias,"smtp",1) > 0 Then
                  OutPutFile.WriteLine User.DisplayName & vbTab & Replace(Alias,"smtp:","",1,1,1)
                  WScript.Echo User.DisplayName & vbTab & Replace(Alias,"smtp:","",1,1,1)
            End If
    'WScript.Echo Alias
        Next
  End If

Case "organizationalunit" , "container"
  EnumerateUsers User

End Select
Next
End Sub
Commented:
Greetings:

Use the csvde command on the server.  It will let you specify which fields you want to export.

http://technet2.microsoft.com/WindowsServer/en/library/1050686f-3464-41af-b7e4-016ab0c4db261033.mspx?mfr=true

ldifde also works but hte format is different.
Commented:
CSVDE would be a little easier to use.  It exports it to a file that excel can read so it is easily modified and formatted.

You can specify which part of the hierarchy you want to export, and you can export specific fields in Active Directory to include smtp addresses.

When we need to move contacts to another exchange system, this is what we use.

There is alsoa  neat utility on the web called ADMODIFY which can help with bulk changes, and exports.
http://www.msexchange.org/articles/ADModify-Change-Exchange-Specific-AD-User-Attributes.html
CERTIFIED EXPERT

Commented:
The script I posted would be a little easier again - all you have to do it run it :)

Author

Commented:
All I really need to do is generate a list of SMTP addresses, I don't need to get the username or anything else.  ADUC saved queries only shows me the primary e-mail address.  The VB script above doesn't show me anything.  I get an error.  The link to a VB script near the top exported a list, but only of 100 or so, not nearly my complete listing.  I have multiple containers my Exchange objects are in, I need a global export of all SMTP address, and only SMTP addresses, nothing else.  Any other ideas?

Author

Commented:
redseattechnologies - I need a listing of all SMTP addresses, your script in the link only did an output of user SMTP addresses, and none of the ones it output had more than 1 address, and I know we have several users who have more than one SMTP address, but no more than 4.  I also need SMTP addresses for mail enabled groups (DL) and also mail enabled public folders not just user accounts.
CERTIFIED EXPERT

Commented:
Indeed, that script will not get DL addresses.

Why you are having problems with it, I don't know.  As it wont get DLs, there is little point troubleshooting it

-red
Commented:
csvde -f c:\ExportedList.csv -l proxyAddresses

Commented:
However -- redseatechnologies has got some excellent scripting solutions for quite a number of issues across the entire network.  I've just never learned code so I use the resources available to me.  He has provided me some great utilities!!!!

Author

Commented:
Yeah I agree, the script was great, just not completely what I need.  I found this one - http://www.drewery.net/blog/2006/10/27/vbscript-to-export-smtp-proxy-addresses/

That works good, but not setup for public folders or DLs.  If I knew LDAP well enough I could probably set it up to do what I need.  Any LDAP guru's out there have any tips or code available that would take the code in the above link and add public folder and DL selections to the query?

Commented:
-red
I do like this code !!!  ... but it doesn't give me the secondary addresses.  
CERTIFIED EXPERT

Commented:
Really?

I didn't write it, but let me test it out and see what is going on

-red
CERTIFIED EXPERT

Commented:
Try this version (later on in the page)

http://www.visualbasicscript.com/fb.aspx?m=34353

It has to be run on a machine with Excel (doesn't have to be a DC though)

-red
Expert of the Year 2007
Expert of the Year 2006
Commented:
I just run this:

Ldifde -d "DC=domain,DC=co,DC=uk" -r "(&(mailnickname=*))" -l proxyAddresses -f proxies.txt

replacing the DC=domain etc with the correct domain name.

Simon.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.