Solved

Bulk change of external email addresses for Mail Contacts - Exchange 2007

Posted on 2015-01-09
4
244 Views
Last Modified: 2015-01-15
Assuming this is going to need powershell.

We have a LOT of mail contacts in the form of user@abc.com. abc.com is changing to xyz.zom so we want to be able to identify and change all of them. Invididually would be a problem.

Can anyone help with necessary commands to to do this?
0
Comment
Question by:paul williams
4 Comments
 
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 40539977
0
 

Author Comment

by:paul williams
ID: 40540073
Thanks but first I need to know how to get a list of contacts with abc.com as their smtp email address before I can change them.
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 250 total points
ID: 40540303
Use the following powershell scripts to accomplish exactly what you need.

import-module activedirectory
add-pssnapin microsoft.exchange.management.powershell.admin
Get-MailContact -resultsize "unlimited" | select Alias | out-file "c:\mailcontacts.csv"

Open in new window


This will give you all of the mail contacts in your environment, and export them to a CSV file.

From there do the following...
- open the CSV remove the second line -----------------------------
- create a second column called NewAddress
- make sure that the CSV file is constructed like below...
Alias             NewAddress
bobprince   bprice@xyz.com
etc...

Then use the next powershell script to change each ExternalEmailAddress respectively...
import-module activedirectory
Add-PSSnapin microsoft.exchange.management.powershell.admin
$UserList = import-csv "c:\mailcontacts.csv"
foreach ($Contact in $UserList) {
$Contact.Alias
$Contact.NewAddress
Get-MailContact -Identity $Contact.Alias | Set-MailConact -ExternalEmailAddress $Contact.NewAddress -Confirm:$False
}

Open in new window


This will then go through the csv and modify each mail contact respectively.

Will.
0
 
LVL 9

Assisted Solution

by:schmiegu
schmiegu earned 250 total points
ID: 40546085
You only need this one line:
Get-MailContact -ResultSize Unlimited | Where {$_.WindowsEmailAddress -match 'abc.com' } | Foreach {Set-MailContact $_.WindowsEmailAddress  $_.WindowsEmailAddress  -Replace "abc" "xyz"}

Open in new window


To first check the contacts:
Get-MailContact -ResultSize Unlimited | Where {$_.WindowsEmailAddress -match 'abc.com' } | ft Name, Alias, WindowsEmailAddress 

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
Find out what you should include to make the best professional email signature for your organization.
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

808 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