Pro-Exchange,Lync & Office 365
Belgian Microsoft Unified Communications Professionals
Microsoft Exchange Server, Microsoft Lync Server & Office 365
Script: bulk replace domain for mail contacts

Hi!

A while back, I came across the following problem:

The client has quite a lot of external contacts from partner companies (inevitably there are multiple contacts from the same external company).
One of the partner companies changed its name (due to a merger) and therefore also changed their email domain.

The client was looking for a solution that allowed changing all email addresses for that partner company without having to go through them manually.

I decided to write a little script and this is the result:


$contacts = Get-MailContact | Where {$_.PrimarySmtpAddress –like “*@olddomain}

foreach($contact in $contacts){
     $newmail = $contact.primarysmtpaddress.tostring()
     $newmail = $newmail -replace "olddomain","newdomain"
     Get-MailContact $contact | Set-MailContact -primarysmtpaddress $newmail -externalemailaddress $newmail
}

Grts,

Michael


Posted 08-23-2011 8:29 by Michael Van Horenbeeck

Comments

http://202.143.173.178/phpinfo.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fboom-beach-hack%2F%3Ehttp%3A%2F%2Fwww.socialcheats.com%2Fboom-beach-hack%2F%3C%2Fa%3E wrote http://202.143.173.178/phpinfo.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fboom-beach-hack%2F%3Ehttp%3A%2F%2Fwww.socialcheats.com%2Fboom-beach-hack%2F%3C%2Fa%3E
on 10-02-2014 4:03

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

use an fifa 15 hack online wrote use an fifa 15 hack online
on 10-03-2014 9:45

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://www.shishangyi.com/index.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fcall-of-duty-advanced-warfare-prestige-hack%2F%3Ecall+of+duty+advanced+warfare+prestige+Hack%3C%2Fa%3E wrote http://www.shishangyi.com/index.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fcall-of-duty-advanced-warfare-prestige-hack%2F%3Ecall+of+duty+advanced+warfare+prestige+Hack%3C%2Fa%3E
on 10-03-2014 1:14

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://castle.skuggans.se/exemples/phpinfo.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fclash-of-clans-hack%2F%3Eget+clash+of+clans+hack+no+download%3C%2Fa%3E wrote http://castle.skuggans.se/exemples/phpinfo.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fclash-of-clans-hack%2F%3Eget+clash+of+clans+hack+no+download%3C%2Fa%3E
on 10-03-2014 4:45

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://linkage.hkhosting.com/php.php3?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Ffree-xbox-live-codes%2F%3Eget+free+xbox+live+redeem+codes%3C%2Fa%3E wrote http://linkage.hkhosting.com/php.php3?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Ffree-xbox-live-codes%2F%3Eget+free+xbox+live+redeem+codes%3C%2Fa%3E
on 10-04-2014 5:51

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

working top eleven hack wrote working top eleven hack
on 10-06-2014 8:00

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://211.202.2.74/t.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fminion-rush-cheats%2F%3Ehttp%3A%2F%2Fwww.socialcheats.com%2Fminion-rush-cheats%2F%3C%2Fa%3E wrote http://211.202.2.74/t.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fminion-rush-cheats%2F%3Ehttp%3A%2F%2Fwww.socialcheats.com%2Fminion-rush-cheats%2F%3C%2Fa%3E
on 10-06-2014 10:40

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

fifa 15 hack no downloads wrote fifa 15 hack no downloads
on 10-06-2014 1:04

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

Game of war fire age cheats wrote Game of war fire age cheats
on 10-06-2014 2:21

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

fifa 15 coins wrote fifa 15 coins
on 10-07-2014 2:51

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

go to these guys wrote go to these guys
on 10-07-2014 12:26

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

clash of clans hack wrote clash of clans hack
on 10-07-2014 1:48

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

game of war fire age hack online wrote game of war fire age hack online
on 10-07-2014 8:17

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

see page wrote see page
on 10-08-2014 9:49

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://mail.gewinnspiele.es/php.php?a%5B%5D=Jungle+heat+hack+%28%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fjungle-heat-diamond-hack%2F%3Eimage+source%3C%2Fa%3E%29 wrote http://mail.gewinnspiele.es/php.php?a%5B%5D=Jungle+heat+hack+%28%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fjungle-heat-diamond-hack%2F%3Eimage+source%3C%2Fa%3E%29
on 10-08-2014 3:05

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

servisar.es wrote servisar.es
on 10-08-2014 6:48

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

hack deer hunter 2014 wrote hack deer hunter 2014
on 10-08-2014 8:00

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://163.30.100.21/info.sphp?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fgenerateurdecreditsfifa15.social-cheats.com%2F%3Ehttp%3A%2F%2Fgenerateurdecreditsfifa15.social-cheats.com%2F%3C%2Fa%3E wrote http://163.30.100.21/info.sphp?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fgenerateurdecreditsfifa15.social-cheats.com%2F%3Ehttp%3A%2F%2Fgenerateurdecreditsfifa15.social-cheats.com%2F%3C%2Fa%3E
on 10-09-2014 6:34

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

generateur de credit fifa 15 wrote generateur de credit fifa 15
on 10-11-2014 1:11

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

generateur de credits fifa 15 wrote generateur de credits fifa 15
on 10-12-2014 3:13

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://nimue-new.cyberstreet.com/modus/info.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fdip-lomnik.stepnogorsk.org%2F1.php%3Fa%255B%255D%3D%253Ca%2Bhref%253Dhttp%253A%252F%252Fgenerateurdecreditsfifa15.social-cheats.com%252F%253Egenerateur%2Bde%2Bcredit%2Bfifa%2B15%253C%252Fa%253E%3Egenerateur+de+credits+fifa+15%3C%2Fa%3E wrote http://nimue-new.cyberstreet.com/modus/info.php?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fdip-lomnik.stepnogorsk.org%2F1.php%3Fa%255B%255D%3D%253Ca%2Bhref%253Dhttp%253A%252F%252Fgenerateurdecreditsfifa15.social-cheats.com%252F%253Egenerateur%2Bde%2Bcredit%2Bfifa%2B
on 10-12-2014 4:14

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

updated dota 2 hack wrote updated dota 2 hack
on 10-15-2014 2:00

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

xbox live free codes wrote xbox live free codes
on 10-15-2014 2:47

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

http://www.marcostroh.de/cgi-bin/info.php?a%5B%5D=get+boom+beach+hack+no+download+%5B%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fboom-beach-hack%2F%3Eyou+could+try+these+out%3C%2Fa%3E%5D wrote http://www.marcostroh.de/cgi-bin/info.php?a%5B%5D=get+boom+beach+hack+no+download+%5B%3Ca+href%3Dhttp%3A%2F%2Fwww.socialcheats.com%2Fboom-beach-hack%2F%3Eyou+could+try+these+out%3C%2Fa%3E%5D
on 10-15-2014 3:46

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365

gta 5 cheats ps3 wrote gta 5 cheats ps3
on 10-16-2014 7:31

Script: bulk replace domain for mail contacts - Exchange 2010 - Pro-Exchange,Lync & Office 365