Joe_27
asked on
Export/Extract All SMTP Address from Windows 2003 Active Directory
Hi Experts,
I have a Windows 2003 Domain, in addition to having Exchange 2003 Enterprise. I have been tasked with gathering all email addresses within the company. To accomplish this task, I used the CSVDE –f <filename> command. When I opened the file, everything seemed to be in order; however, the proxy address column had additional information. Not only did it pull the SMTP addresses, but it also pulled the X400, CCMail, and MS fields as well.
Does anyone have a script or know of anything that just extracts only information contained within SMTP addresses? I would hate to have to go through rows and rows of an Excel worksheet, deleting the unnecessary information.
Thanks for your help.
I have a Windows 2003 Domain, in addition to having Exchange 2003 Enterprise. I have been tasked with gathering all email addresses within the company. To accomplish this task, I used the CSVDE –f <filename> command. When I opened the file, everything seemed to be in order; however, the proxy address column had additional information. Not only did it pull the SMTP addresses, but it also pulled the X400, CCMail, and MS fields as well.
Does anyone have a script or know of anything that just extracts only information contained within SMTP addresses? I would hate to have to go through rows and rows of an Excel worksheet, deleting the unnecessary information.
Thanks for your help.
Sorry...meant AD Users & Computers...and this does not work well for a large enterprise.
See if this link helps:
http://www.msexchange.org/tutorials/Creating_a_list_of_Users_and_their_email_addresses_in_Exchange_2000_2.html
http://www.msexchange.org/tutorials/Creating_a_list_of_Users_and_their_email_addresses_in_Exchange_2000.html
See if this link helps:
http://www.msexchange.org/tutorials/Creating_a_list_of_Users_and_their_email_addresses_in_Exchange_2000_2.html
http://www.msexchange.org/tutorials/Creating_a_list_of_Users_and_their_email_addresses_in_Exchange_2000.html
Retrieving all the e-mail addresses is really easy (when you know how of course). Do you need anything more than the e-mail addresses? The account they're associated with for example?
If you just want a plain list then this will extract them for you and dump them to Addresses.txt (save as <something>.vbs and run it):
Option Explicit
' Global Constants
Const ADS_SCOPE_SUBTREE = 2
' Global Variables
Dim objFileSystem, objFile, objRootDSE
Dim strDomainName
'
' Subroutines
'
Sub FindAddress
' Runs a simple AD Query to find proxyAddresses.
Dim objConnection, objCommand, objRecordSet
Dim strAddress
Dim arrAddresses
Set objConnection = CreateObject("ADODB.Connec
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Comman
objCommand.ActiveConnectio
objCommand.CommandText = "SELECT proxyAddresses FROM 'LDAP://" & strDomainName & "'"
objCommand.Properties("Pag
objCommand.Properties("Tim
objCommand.Properties("Sea
objCommand.Properties("Cac
Set objRecordSet = objCommand.Execute
While Not objRecordSet.EOF
On Error Resume Next
arrAddresses = objRecordSet.Fields("proxy
For Each strAddress in arrAddresses
If InStr(1, strAddress, "smtp:", VbTextCompare) Then
objFile.WriteLine Replace(LCase(strAddress),
End If
Next
On Error Goto 0
objRecordSet.MoveNext
Wend
objConnection.Close
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
End Sub
'
' Main Code
'
Set objFileSystem = CreateObject("Scripting.Fi
Set objFile = objFileSystem.OpenTextFile
Set objRootDSE = GetObject("LDAP://RootDSE"
strDomainName = objRootDSE.Get("defaultNam
WScript.Echo "Searching Domain: " & strDomainName & VbCrLf
FindAddress
Set objFile = Nothing
Set objFileSystem = Nothing
Oh anad the script should be run as Administrator... the SQL queries are a little fussy about access rights.
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nice VBScript!
Hi ingetic - your idea works great for users but I can't work out how to use it to get group email addresses.
Hi Chris-Dent - your idea works well and being a program I'm sure someone can tell me how I could modify it to also get the Display Name and Type for each object returned, inlcuding users and groups.
Thanks
Barry
Hi Chris-Dent - your idea works well and being a program I'm sure someone can tell me how I could modify it to also get the Display Name and Type for each object returned, inlcuding users and groups.
Thanks
Barry
ASKER
Yes, the display name and type would be great info to have also.
Very easy to add - how do you want it to be displayed?
ASKER
If it's possible, Display Name, Type, smtp addresses
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for group, you can use :
dsquery group
dsquery group
Hi Ingetic
dsquery group works but then it won't let me do dsget group -email. Is there a way of extracting the email addresses for groups like that?
I'll give Chris-Dent's suggestion a go when I'm back in the office.
Thanks to both of you for the ideas - I posted my first question on the Outlook section (about linked addresses in distribution lists) a couple of weeks ago and got zero response, which surprised me. This thread just shows how well Experts Exchange works with everyone contributing.
Regards
Barry
dsquery group works but then it won't let me do dsget group -email. Is there a way of extracting the email addresses for groups like that?
I'll give Chris-Dent's suggestion a go when I'm back in the office.
Thanks to both of you for the ideas - I posted my first question on the Outlook section (about linked addresses in distribution lists) a couple of weeks ago and got zero response, which surprised me. This thread just shows how well Experts Exchange works with everyone contributing.
Regards
Barry
I didn't ask the question but I did join in and get some useful help so I would recommend splitting the points with the larger share to Chris_Dent for his vbscript and ingetic for the command line idea.
Just my 2 cents worth.
Thanks guys for the help
Barry
Just my 2 cents worth.
Thanks guys for the help
Barry
Bob