locked
Bulk change the primary/reply-to domain in Office 365 RRS feed

  • Question

  • We are rebranding our company and therefore changing the email address displayed on outgoing emails.  I know how to change it for one user.  Is there a way to change it for all users at once?  We also do not want to change their login email address, only their exchange address.  We also need to keep the current address as an alternative.  Can anyone help me out?
    Friday, January 2, 2015 9:22 PM

Answers

  • try:

    $NewEmailDomain = '@MyDomain.com'
    Get-User -ResultSize:Unlimited | Get-Mailbox -ErrorAction ignore | % { 
        $_.EmailAddresses.Add("smtp:$($_.Alias)$NewEmailDomain") 
        Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses 
    }

    put the new domain in the first line..



    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx


    You'll need to add the -WindowsEmailAddress parameter to the script to make the new address the default:

    $NewEmailDomain = '@MyDomain.com'
    $Mailboxes = Get-Mailbox -ResultSize Unlimited 
    foreach ($Mailbox in $Mailboxes)
    { 
        $Address = "smtp:$($Mailbox.Alias)$NewEmailDomain"
        $Mailbox.EmailAddresses.Add($Address) 
        Set-Mailbox -Identity $Mailbox.Identity -EmailAddresses $Mailbox.EmailAddresses -WindowsEmailAddress $Address
    }

    Also, there is no reason to have the Get-User command in there - just grab all the mailboxes.

    If you have federated users then you will need to set the primary smtp address in Active Directory, but OP stated you needed to do this in Office 365 so I am assuming he is authoring identities in the cloud.


    • Edited by Matt McNabb Saturday, January 3, 2015 4:35 AM
    • Marked as answer by Nick Summy Monday, January 5, 2015 7:20 AM
    Saturday, January 3, 2015 4:34 AM

All replies

  • try:

    $NewEmailDomain = '@MyDomain.com'
    Get-User -ResultSize:Unlimited | Get-Mailbox -ErrorAction ignore | % { 
        $_.EmailAddresses.Add("smtp:$($_.Alias)$NewEmailDomain") 
        Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses 
    }

    put the new domain in the first line..



    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx


    • Edited by Sam Boutros Friday, January 2, 2015 11:04 PM
    Friday, January 2, 2015 11:03 PM
  • That won't change the deafult address.  YOu need to change the replyto field and I believe that is best done with a rule.

    I would ask the quession in the Exhange forum.  It does not require a script.

    If you really do want to cahnge the default priamry email address then cahnge the address generator rule to generate a new primary.  THat way all new users will get the correct new domain. Using a script will force you to rerun  it every time you add a user.  Remeber that the email addresses are generated by the address generator rule.  The rule can override any manually applied addresses.

    Again - it would be better to talk this over with teh Exhange forumbecause there can be other considerations.

    Assume everone gets a new SMTP domain.  You can set that in the generator in one line.


    ¯\_(ツ)_/¯

    Saturday, January 3, 2015 12:42 AM
  • try:

    $NewEmailDomain = '@MyDomain.com'
    Get-User -ResultSize:Unlimited | Get-Mailbox -ErrorAction ignore | % { 
        $_.EmailAddresses.Add("smtp:$($_.Alias)$NewEmailDomain") 
        Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses 
    }

    put the new domain in the first line..



    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx


    You'll need to add the -WindowsEmailAddress parameter to the script to make the new address the default:

    $NewEmailDomain = '@MyDomain.com'
    $Mailboxes = Get-Mailbox -ResultSize Unlimited 
    foreach ($Mailbox in $Mailboxes)
    { 
        $Address = "smtp:$($Mailbox.Alias)$NewEmailDomain"
        $Mailbox.EmailAddresses.Add($Address) 
        Set-Mailbox -Identity $Mailbox.Identity -EmailAddresses $Mailbox.EmailAddresses -WindowsEmailAddress $Address
    }

    Also, there is no reason to have the Get-User command in there - just grab all the mailboxes.

    If you have federated users then you will need to set the primary smtp address in Active Directory, but OP stated you needed to do this in Office 365 so I am assuming he is authoring identities in the cloud.


    • Edited by Matt McNabb Saturday, January 3, 2015 4:35 AM
    • Marked as answer by Nick Summy Monday, January 5, 2015 7:20 AM
    Saturday, January 3, 2015 4:34 AM
  • Please look at the question. For Exchange 2013 Online (O365) this is the command.

    # Exchange 2013
    
    Set-Mailbox -Identity <alias> -EmailAddressPolicyEnabled:$False -PrimarySMTPAddress <smtpaddress> -WindowsEmailAddress <smtpaddress> -Emailddresses @(<addresses>)
    
    #
    
    

    The question states setting "Reply-To" address.  "Reply-To" is an Outlook setting"  It is a user acountconfiguration option that can be set to other than the "Promary" address.

    As stated above.  If you set the address you must either use a policy (rule) or you must disable the policy on the mailbox.

    Nether getting all of the mailboxes with Set-Mailbox and a wild card nor using just Get-User will work because you will get system, room and other utility mailboxes which you may not want to change.

    I suspect you don't want to chnage to WindowsEmailAddress but I have posted it to show that it is available without accessing AD.

    See: http://technet.microsoft.com/en-us/library/bb123981(v=exchg.141).aspx

    If you set "PromarySMTPAddress" it will become the reply to but Outlook can still override this.  I have not checked to see if Outlook online can override it.


    ¯\_(ツ)_/¯

    Saturday, January 3, 2015 12:50 PM
  • Saturday, January 3, 2015 12:59 PM
  • For O365 you should aos read this before attempting to make any changes:

    http://community.office365.com/en-us/f/158/t/85683.aspx


    ¯\_(ツ)_/¯

    Saturday, January 3, 2015 1:14 PM
  • JRV,

    -PrimarySTMPAddress is only for On-Prem Exchange, not O365.

    EmailAddressPolicyEnabled is set to false by default, at least in my tenant, so I didn't include that parameter since it seems outside of the scope of the OP's question. 

    Saturday, January 3, 2015 3:26 PM
  • JRV,

    -PrimarySTMPAddress is only for On-Prem Exchange, not O365.

    EmailAddressPolicyEnabled is set to false by default, at least in my tenant, so I didn't include that parameter since it seems outside of the scope of the OP's question. 

    Then the EmailAddresses would use an uppercase SMTP to set the primary address.


    ¯\_(ツ)_/¯

    Saturday, January 3, 2015 3:30 PM
  • That's correct. I was showing a way to accomplish the same without text manipulation since that would add a bit more code.
    Saturday, January 3, 2015 5:20 PM
  • I suspect the real issue here is that the doamin needs to be changed.

    I had a simiar issue when I added users to the O365 implemetation before migrating the domain from the defualt MSOnline domain.  ALl of the addresses were set up but the default domain not updated n the exisiting users.  I could change them manually but they did not update as expected and many things in O365 did not work correctly.  It took MS support over a month to fix this.  We had to manual edit all SharePoint configurations and adjust all users.

    Any new users were created correctly.

    If this is the case here then I suggest posting in the forum I linked above or contatcing MSSupport as there can be other issues when this happens.


    ¯\_(ツ)_/¯

    Saturday, January 3, 2015 5:38 PM
  • Here is part of the issue particularly in a hyvrid installation.

    https://support.microsoft.com/kb/2836370?wa=wsignin1.0

    I would use PowerShell to update all mailboxes to use policy then change the pollicy.  ll issues including default SMTP can be set globally saving much time.  Too bad ther is no way yet to force all new mailboxes to use policy although you can if you create mailboxes with PowerShell.


    ¯\_(ツ)_/¯



    • Edited by jrv Saturday, January 3, 2015 5:50 PM
    Saturday, January 3, 2015 5:43 PM
  • Here is part of the issue particularly in a hyvrid installation.

    https://support.microsoft.com/kb/2836370?wa=wsignin1.0

    I would use PowerShell to update all mailboxes to use policy then change the pollicy.  ll issues including default SMTP can be set globally saving much time.  Too bad ther is no way yet to force all new mailboxes to use policy although you can if you create mailboxes with PowerShell.


    ¯\_(ツ)_/¯



    A little research shows that, apparently, recipient policies are only available on hybrid installations.


    ¯\_(ツ)_/¯

    Saturday, January 3, 2015 5:51 PM
  • Thanks Matt, this worked with a few changes I had to make.  I had already ran a script to add the new domain as a secondary domain, so to stop errors I had to remove this command:

    $Mailbox.EmailAddresses.Add($Address) 

    Secondly it didn't not like the "smtp:"  In that first line after the brackets, it was appending that actual phrase to each email address.  I removed that and the script ran without error and made the changes I needed.  Thank you for your help

    And for those confused by the reply-to address thing, it is confusing but it is what Office 365 calls it.  The default email address for the user isn't called the default.  It's called the reply-to address.  When you think of reply-to you think of a setting in outlook or maybe a rule, but thats not the case for this.  Sorry for the confusion!

    Monday, January 5, 2015 7:30 AM
  • Thanks Matt, this worked with a few changes I had to make.  I had already ran a script to add the new domain as a secondary domain, so to stop errors I had to remove this command:

    $Mailbox.EmailAddresses.Add($Address) 

    Secondly it didn't not like the "smtp:"  In that first line after the brackets, it was appending that actual phrase to each email address.  I removed that and the script ran without error and made the changes I needed.  Thank you for your help

    And for those confused by the reply-to address thing, it is confusing but it is what Office 365 calls it.  The default email address for the user isn't called the default.  It's called the reply-to address.  When you think of reply-to you think of a setting in outlook or maybe a rule, but thats not the case for this.  Sorry for the confusion!

    Nick,

    Just to clarify further, JRV is correct that the reply-to email address is actually something that Outlook provides, but in Exchange Online this is simplified a bit for us. The WindowsEmailAddress attribute corresponds to the Mail attribute in AD, and the PrimarySMTPAddress corresponds to the email address with the 'SMTP:' string (all caps.) In an on-prem or hybrid scenario these can be two different addresses and Exchange knows how to handle this. However in Exchange Online these two tend to follow each other and Outlook uses the PrimarySMTPAddress as the reply-to address. Hence why you use the -WindowsEmailAddress parameter to set the PrimarySMTPAddress.

    Monday, January 5, 2015 1:26 PM
  • Hi Matt,

    thx for this reply.

    But will the script change the Azure AD credentials? 

    Tuesday, August 27, 2019 1:55 PM
  • Please use the vote button instead of reactivating an old thread.

    If you have a question create a new thread. If needed you can link this one to refer to it.

    Thanks


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, August 27, 2019 2:02 PM
    Tuesday, August 27, 2019 2:00 PM