locked
How to edit multiple mail contact with EMS RRS feed

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