question

sil4-1439 avatar image
0 Votes"
sil4-1439 asked ·

Office 365 - Change all emails to first.lastname@domain but keep the login email

Hi Guys,

we have around 1500 mailboxes on Office365 and the Company asked us to Change all Email Address to:
Firstname.lastname@Domain.com BUT we need to keep the Login Email the same so it wont cause disconnection on all outlooks

I've been trying to find the proper PS script online but couldn't found one that matches the office365

would love to get some help on this one

windows-server-powershelloffice-exchange-online-itpro
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

michev avatar image
1 Vote"
michev answered ·

First things first - are those users provisioned directly in the cloud or being synchronized from AD/external system? In the latter scenario, you will need to make the changes there and wait for sync to happen.
If they are managed directly in Azure AD, you can use the following cmdlet:

 Set-Mailbox user@domain.com -WindowsEmailAddress new@domain.com

The above will add new@domain.com as the current primary SMTP address, while keeping the old one as secondary address, and is the easier way to make this change in O365. You can run this in bulk based off a CSV file or just directly leverage the firstname/lastname values for each user. Here's an example for the former:
https://social.technet.microsoft.com/Forums/msonline/en-US/66165391-1bb9-4925-a2e7-fbe701654b00/bulk-change-primary-smtp?forum=onlineservicesexchange

· 6 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your reply Michev
these users are in cloud only
unfortunately i did not find any way to do the firstname.lastname from the link provided


0 Votes 0 ·

You're supposed to prepare a CSV with that data and use it as input. If you want to do it all "dynamically" you can use something like this:

 Get-User -RecipientTypeDetails UserMailbox | % { Set-Mailbox $_.UserPrincipalName -WindowsEmailAddress "$($_.FirstName)`.$($_.LastName)@domain.com" -WhatIf}

This of course is a very simple example which lacks any error checking, and should be used just to illustrate the idea.

1 Vote 1 ·

Thank you,

eventually i was able to solve it without csv:


Get-User -RecipientTypeDetails "UserMailbox" -ResultSize Unlimited | Select-Object firstname , lastname, WindowsEmailAddress | ForEach-Object {

         $newUPN = '{0}.{1}@domain.com' -f $_.firstname,$_.lastname
         $user = $_.WindowsEmailAddress
                        
         Try{                
              #Set-Mailbox -Identity $_.WindowsEmailAddress -WinldowsEmailAddress $newUPN
              Write-Host $newUPN
            }
         Catch{
             Write-Output "####################"
             Write-Output $user
             Write-Output $ErrorMessage = $_.Exception.Message
             Write-Output $FailedItem = $_.Exception.ItemName
             Write-Output "####################"

1 Vote 1 ·
Show more comments
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ·

You only need to change the Exchange Email Address Policy for your organization. Exchange will preserve the current email addresses for each mailbox as a secondary SMTP proxy address and change the primary SMTP address as per the policy that's applicable to the mailbox-enabled or mail-enabled objects.

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

But You cannot change users Email address policy on office 365
only on Microsoft 365 Groups
at least that's what Microsoft told me

0 Votes 0 ·