Solved

Export complete list of SMTP addresses

Posted on 2006-11-07
17
1,020 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
0
Comment
Question by:MCPJoe
  • 5
  • 5
  • 4
  • +2
17 Comments
 
LVL 9

Expert Comment

by:trenes
ID: 17892990
Hi MCPJoe,

Do this in command prompt.

dsquery user | dsget user -email


Cheers!
0
 
LVL 39

Assisted Solution

by:redseatechnologies
redseatechnologies earned 50 total points
ID: 17893006
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
 
LVL 9

Author Comment

by:MCPJoe
ID: 17893018
All I get are 100 default entries in the output, what syntax do I use the -limit argument to get all my records?
0
 
LVL 9

Assisted Solution

by:trenes
trenes earned 50 total points
ID: 17893058
'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
 
LVL 18

Assisted Solution

by:kjanicke
kjanicke earned 150 total points
ID: 17893062
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
 
LVL 18

Assisted Solution

by:kjanicke
kjanicke earned 150 total points
ID: 17893093
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
 
LVL 39

Expert Comment

by:redseatechnologies
ID: 17893152
The script I posted would be a little easier again - all you have to do it run it :)
0
 
LVL 9

Author Comment

by:MCPJoe
ID: 17893155
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Author Comment

by:MCPJoe
ID: 17893169
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
 
LVL 39

Expert Comment

by:redseatechnologies
ID: 17893276
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
 
LVL 18

Assisted Solution

by:kjanicke
kjanicke earned 150 total points
ID: 17893434
csvde -f c:\ExportedList.csv -l proxyAddresses
0
 
LVL 18

Expert Comment

by:kjanicke
ID: 17893461
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
 
LVL 9

Author Comment

by:MCPJoe
ID: 17893486
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
 
LVL 18

Expert Comment

by:kjanicke
ID: 17893495
-red
I do like this code !!!  ... but it doesn't give me the secondary addresses.  
0
 
LVL 39

Expert Comment

by:redseatechnologies
ID: 17893505
Really?

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

-red
0
 
LVL 39

Expert Comment

by:redseatechnologies
ID: 17893565
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
 
LVL 104

Accepted Solution

by:
Sembee earned 250 total points
ID: 17894295
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

Featured Post

The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
In this video we show how to create a User Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Mailb…
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now