• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1074
  • Last Modified:

Export complete list of SMTP addresses

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
0
MCPJoe
Asked:
MCPJoe
  • 5
  • 5
  • 4
  • +2
6 Solutions
 
trenesCommented:
Hi MCPJoe,

Do this in command prompt.

dsquery user | dsget user -email


Cheers!
0
 
redseatechnologiesCommented:
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
0
 
MCPJoeAuthor Commented:
All I get are 100 default entries in the output, what syntax do I use the -limit argument to get all my records?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
trenesCommented:
'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
0
 
kjanickeCommented:
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.
0
 
kjanickeCommented:
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
0
 
redseatechnologiesCommented:
The script I posted would be a little easier again - all you have to do it run it :)
0
 
MCPJoeAuthor 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?
0
 
MCPJoeAuthor 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.
0
 
redseatechnologiesCommented:
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
0
 
kjanickeCommented:
csvde -f c:\ExportedList.csv -l proxyAddresses
0
 
kjanickeCommented:
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!!!!
0
 
MCPJoeAuthor 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?
0
 
kjanickeCommented:
-red
I do like this code !!!  ... but it doesn't give me the secondary addresses.  
0
 
redseatechnologiesCommented:
Really?

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

-red
0
 
redseatechnologiesCommented:
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
0
 
SembeeCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 5
  • 5
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now