Answered by:
How to edit multiple mail contact with EMS

Question
-
Hi,
I need to change few hundred mail contact becouse their provider has changed domain name. I have this situation:
and I need to change to:
I tried with command Set-MailContact but only for single edit. Windows Server 2008R2 SP1 and Exchange 2010 SP1 is my configuration.
Friday, May 27, 2011 7:54 AM
Answers
-
Try this, the script gets the contact object and creates a new address for each address that ends with '@domain.com'.
Test in a lab environment before running in production.
Get-MailContact -ResultSize Unlimited | Foreach-Object {
$NewEmailAddresses = $_.EmailAddresses | Foreach-Object {
if($_.PrefixString -eq 'smtp' -and $_.SmtpAddress -like '*@domain.com' )
{
$new = $_.SmtpAddress -replace '@domain.com','@something.com'
if($_.IsPrimaryAddress)
{
([Microsoft.Exchange.Data.SmtpProxyAddress]$new).ToPrimary()
}
else
{
[Microsoft.Exchange.Data.SmtpProxyAddress]$new
}
}
else
{
$_
}
}
$_ | Set-MailContact -EmailAddresses $NewEmailAddresses -EmailAddressPolicyEnabled $false
}
Shay Levy [MVP]
PowerShay.com
PowerShell Toolbar- Marked as answer by Alan Zhu Friday, June 3, 2011 2:27 AM
Monday, May 30, 2011 1:39 PM
All replies
-
Hi,
Have you looked at “E-mail Address Policies” in EMC under Organization Configuration, Hub Transport?
J
Friday, May 27, 2011 1:28 PM -
Hi,
You can use the ADModify to Change Exchange Specific AD User Attributes in Bulk:
http://www.msexchange.org/articles/ADModify-Change-Exchange-Specific-AD-User-Attributes.html
Meanwhile, your thread is related with the Exchange Server, I would suggest you create one thread to specially ask this questions on the Exchange Forum:
Exchange Server
http://social.technet.microsoft.com/Forums/en-US/category/exchangeserver
Thanks.
Monday, May 30, 2011 6:13 AM -
Thank you for suggestion, I will try on Exchange forum.Monday, May 30, 2011 7:38 AM
-
Try this, the script gets the contact object and creates a new address for each address that ends with '@domain.com'.
Test in a lab environment before running in production.
Get-MailContact -ResultSize Unlimited | Foreach-Object {
$NewEmailAddresses = $_.EmailAddresses | Foreach-Object {
if($_.PrefixString -eq 'smtp' -and $_.SmtpAddress -like '*@domain.com' )
{
$new = $_.SmtpAddress -replace '@domain.com','@something.com'
if($_.IsPrimaryAddress)
{
([Microsoft.Exchange.Data.SmtpProxyAddress]$new).ToPrimary()
}
else
{
[Microsoft.Exchange.Data.SmtpProxyAddress]$new
}
}
else
{
$_
}
}
$_ | Set-MailContact -EmailAddresses $NewEmailAddresses -EmailAddressPolicyEnabled $false
}
Shay Levy [MVP]
PowerShay.com
PowerShell Toolbar- Marked as answer by Alan Zhu Friday, June 3, 2011 2:27 AM
Monday, May 30, 2011 1:39 PM -
Thank you all for replay. I am away this week and on Monday I will test this script and I hope mark as answer :)
edit: this is a script that is working for me.
Tuesday, May 31, 2011 9:45 PM