Part of the way my current employer has grown is through acquisitions and mergers. Consequently we’ve been supporting more than 10 legacy SMTP domains from various shipping lines. Now that we’re decommissioning our systems it’s time to do some housekeeping and discontinue these domains.
The first step was to check that all objects had their primary SMTP address set to the main domain name. This was done more than a year ago but needed to be reconfirmed. A custom LDAP query that included the syntax (!mail=*@our_main_domain.com) sufficed.
Next I wrote a script that exported all SMTP proxy addresses for user objects. This was to be used as a reference in the unlikely event that problems arose down the line. The LDAP query can easily be modified for groups, contacts and public folders. It’s not the most exciting of scripts but it does the job. You can download it here: AllSMTPProxies.vbs.txt
As I wanted to be very specific and meticulous in the removal of legacy proxy addresses I wrote another script that targets a specific SMTP domain. In this script you can specify the domain by changing the strSMTPDomain value. The script will then only export the names and addresses for proxies that match the SMTP domain. You can download the script here: SpecificSMTPProxies.vbs.txt
In my next post I’ll be using PutEx in a script to remove proxy addresses from AD objects.
Is there any way to have this script also export public folder and Distribution list addresses. It worked great for my users, but I also need a report of public folder and DL SMTP addresses…
Thanks
By: Joe on November 7, 2006
at 9:49 pm
By: Ant on November 8, 2006
at 8:05 am
I use a script to upload a white list to our spam filter provider. My problem is that I can get all mail addresses and all DL addresses. I cannot get the secondary smtp addresses. Is this possible.
example.
primary = jim.gingrich
James.gingrich is not returned in the query.
Thanks in Advance
By: Jim Gingrich on November 17, 2006
at 4:23 pm
The current script is looking for = “smtp:”, so the script only pulls the secondary addresses. Primary addresses are formatted in CAPS, so you can force all address to lower-case by using the LCase() function:
For Each Address In arrProxyAddresses
If LCase(left(Address,5))= “smtp:” Then
objTextFile.writeLine(FoundObject.Displayname & vbTab & Address)
That’s it! Nice and simple.
Good Luck
End if
Next
By: Tony Massa on January 4, 2007
at 5:08 am
How would you go about modifying the script to connect to a different domain? We run a resource domain model and my machine is not a member of the domain that holds the Exchange Org.
Thanks!
By: Mark Lencioni on January 19, 2007
at 6:15 pm
The script does not handle users with only one primary SMTP proxy address.
By: Han on December 5, 2007
at 9:51 am
When I modify your script to use the group or public folder object class the following is returned when the script executes: “(49, 2) Microsoft VBScript runtime error: Object not a collection”. No output is generated. Any idea what would cause this?
Thanks……………..Eric
By: Eric on January 15, 2008
at 12:11 am
Hi,
I also recived the folllowinmg error, one txt file is created, but only with 3 to 4 names, the script gave the following error
Line: 49
Char: 2
Error: Obejct not a collection
Code : 800A01c3
Source: Microsoft VBScript runtime error
By: Abhi on January 21, 2008
at 6:35 am
I had the same error…
Line: 49
Char: 2
Error: Obejct not a collection
Code : 800A01c3
Source: Microsoft VBScript runtime error
I found out that some users had no secondary address (proxyAddress) and the script failed because it can’t process it.
To solve this I added the line:
If IsArray(arrProxyAddresses) Then…
before the line:
For Each Address In arrProxyAddresses…
to verify that arrProxyAddresses was an array (collection) before it gets processed as one.
By: Alex on August 14, 2008
at 9:59 pm
I edited the script to gather all mail enabled groups – and didn’t change “smtp:” – so it pulled all groups that had proxy addresses, and then bombed out when it got to one that didn’t have a “smtp:” lowercase. I simply changed the line to “SMTP:” and that grabbed and listed the primary SMTP address for each group. Simple enough.
If left(Address,5)= “SMTP:” Then
By: David on February 24, 2009
at 6:34 pm
Wav… exactly what I needed
Thanks
“AllSMTPProxies.vbs.txt”
By: Perfort on June 2, 2009
at 1:00 am
Great blog, reading it through RSS feed as well
By: James Bower on September 7, 2009
at 9:28 pm
What if you want to export non-SMTP types? Like CCMail or DIR? I tried updating the script to:
If left(Address,5)= “DIR:” Then
and it finds nothing. Works great for smtp: and SMTP:
any thoughts?
By: Steve on October 20, 2009
at 2:50 pm
Is there any way to modify this script to import SMTP proxy addresses? Basically with the exported text file from this script I would like to do a find and replace with the new domain name and then import this back into Exchange.
By: Gabe on February 2, 2010
at 10:19 pm
Don’t forget if you do follow Alex’s suggestion you need to put an END IF in after the NEXT so the whole code segment reads:
Set FoundObject = GetObject (rs.Fields(0).Value)
arrProxyAddresses = FoundObject.proxyAddresses
If IsArray(arrProxyAddresses) then
For Each Address In arrProxyAddresses
If left(Address,5)= “smtp:” Then
objTextFile.writeLine(FoundObject.Displayname & vbTab & Address)
End if
Next
end if
By: Brian on March 26, 2010
at 10:55 am
Is there anyway this script can output all publicfolders that have the “hide from address book” flag set
if not does anybody know how to get a list of publicfolders that are email enabled and change the msExchHideFromAddressLists to false so that they do show in the addressbook.
thanks in advance
andy
By: Andy on July 8, 2010
at 11:45 am
Andy,
If you just run a script to change the HideFromAddressLists field on all groups with the ‘On Error Resume Next’ in the script, it should work. It will fail on those with it already unchecked, but still continue. Let me know if this works.
By: Ken on July 28, 2010
at 9:32 pm
Wondering if there is a way to get this script to read a list of users from a txt file to process. Need to update the email addresses of groups of users after they ar migrated to the new domain. I already have it modified to make the change to the email addresses, just need to read users from a text file and add the line to update the users account.
Thanks in advance
Ken
By: Ken on July 28, 2010
at 9:29 pm
Hi thanks for the response, however I’m not sure how to run the script over all objects. any clues
By: Andy on July 29, 2010
at 1:15 pm
Great script BUT, can the export NOT include the word smtp: before the addresses?
By: Chris on April 17, 2012
at 7:56 am
jaysus, just edit the script and remove “smtp:”
By: Seán Connolly (@drlargepants) on April 25, 2012
at 4:09 pm
What a great little script! Vesatile and easy to show primary as well as secondary proxies.
By: Ralph "the Surfer" lange on June 21, 2012
at 3:31 pm
[…] Export the X500 addresses from Exchange 2003 server (You can refer to this link on how to do […]
By: MSBLOG » Blog Archive » Creating Users in Bulk without Dirsync on Office365 on September 1, 2012
at 2:42 am
For the object not a collection, that means there wasn’t any addresses in the proxyAddresses list and the script is expecting a collection therefore failing. To ignore this error, add to the first line of code:
On Error Resume Next
also to capture both Primary(SMTP:) and Secondary(smtp:) change the line:
If Left(Address,5)= “smtp:” then
to
If Left(LCase(Address),5)= “smtp:” Then
this will convert all strings in the address to lowercase prior to processing the line.
To export x500 addresses, change the
If Left(LCase(Address),5)= “smtp:” Then
to
If Left(LCase(Address),5)= “x500:” Then
and the same for x400.
By: Mac MacAnanny on February 13, 2013
at 5:51 pm
to remove the SMTP prior to exporting, you can change this line as well:
objTextFile.writeLine(FoundObject.Displayname & vbTab & Address)
to:
objTextFile.writeLine(FoundObject.Displayname & vbTab & replace(replace(Address,”SMTP:”,””),”smtp:”,””)
removing the SMTP from the search string will export all addresses, not just SMTP.
Or you could just put the results in excel after and edit/replace.
By: Mac MacAnanny on February 13, 2013
at 5:54 pm
[…] Export the X500 addresses from Exchange 2003 server (You can refer to this link on how to do […]
By: MSBLOG » Blog Archive » Creating Users in Bulk without Dirsync on Office365 on October 13, 2013
at 12:50 pm