SOLVED

Exchange Online - Change primary email address, name and alias of a shared mailbox

%3CLINGO-SUB%20id%3D%22lingo-sub-1219644%22%20slang%3D%22en-US%22%3EExchange%20Online%20-%20Change%20primary%20email%20address%2C%20name%20and%20alias%20of%20a%20shared%20mailbox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1219644%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20been%20asked%20by%20HR%20to%20change%20the%20email%20address%2C%20name%20and%20alias%20of%20a%20few%20shared%20mailboxes%20that%20were%20set%20up%20last%20year.%20For%20example%2C%20I%20need%20to%20change%20%22jobs-mathssec%40domain.com%22%20into%20%22jobs-maths%40domain.com%22%2C%20and%20the%20name%2Falias%20consequently.%20I%20need%20to%20do%20the%20same%20for%209%20other%20mailboxes%20which%20have%20%22sec%22%20in%20the%20email%20address.%3C%2FP%3E%3CP%3EIs%20it%20safe%20to%20run%20the%20following%20command%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Eset-mailbox%20jobs-mathssec%40domain.com%20-EmailAddress%20%22SMTP%3Ajobs-maths%40domain.com%22%2C%22smtp%3Ajobs-maths%40domain.onmicrosoft.com%22%20-Name%20jobs-maths%20-DisplayName%20jobs-maths%20-Alias%20jobs-maths%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWill%20the%20old%20name%20stay%20in%20other%20properties%3F%20I%20would%20need%20to%20keep%20all%20the%20old%20emails%20sent%20to%20the%20old%20address.%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20for%20your%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1219644%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1220347%22%20slang%3D%22en-US%22%3ERe%3A%20Exchange%20Online%20-%20Change%20primary%20email%20address%2C%20name%20and%20alias%20of%20a%20shared%20mailbox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1220347%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20changing%20the%20primary%20SMTP%20address%2C%20it's%20usually%20a%20good%20idea%20to%20keep%20the%20old%20one%20as%20secondary%2C%20to%20avoid%20unnecessary%20NDRs.%20So%20in%20the%20syntax%20you%20used%2C%20make%20sure%20to%20add%20it%20as%20well%2C%20or%20you%20can%20use%20the%20-WindowsEmailAddress%20parameter%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESet-Mailbox%20user%20-WindowsEmailAddress%20%3CA%20href%3D%22mailto%3Anewuser%40domain.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Enewuser%40domain.com%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ewhich%20basically%20changes%20the%20primary%20address%20to%20the%20value%20you%20specify%2C%20while%20preserving%20the%20old%20one%20as%20secondary.%20Then%20do%20the%20rest%20of%20the%20attributes%20as%20needed.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1221573%22%20slang%3D%22en-US%22%3ERe%3A%20Exchange%20Online%20-%20Change%20primary%20email%20address%2C%20name%20and%20alias%20of%20a%20shared%20mailbox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1221573%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%20for%20your%20help!%3C%2FP%3E%3CP%3EI%20will%20add%20that%20parameter%20to%20the%20script!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi All,

 

I have been asked by HR to change the email address, name and alias of a few shared mailboxes that were set up last year. For example, I need to change "jobs-mathssec@domain.com" into "jobs-maths@domain.com", and the name/alias consequently. I need to do the same for 9 other mailboxes which have "sec" in the email address.

Is it safe to run the following command:

 

set-mailbox jobs-mathssec@domain.com -EmailAddress "SMTP:jobs-maths@domain.com","smtp:jobs-maths@domain.onmicrosoft.com" -Name jobs-maths -DisplayName jobs-maths -Alias jobs-maths

 

Will the old name stay in other properties? I would need to keep all the old emails sent to the old address.

Thank you in advance for your help!

5 Replies
best response confirmed by fstorer (Contributor)
Solution

When changing the primary SMTP address, it's usually a good idea to keep the old one as secondary, to avoid unnecessary NDRs. So in the syntax you used, make sure to add it as well, or you can use the -WindowsEmailAddress parameter:

 

Set-Mailbox user -WindowsEmailAddress newuser@domain.com

 

which basically changes the primary address to the value you specify, while preserving the old one as secondary. Then do the rest of the attributes as needed.

Thank you @Vasil Michev for your help!

I will add that parameter to the script! 

@Vasil Michev Hi, I currently have the same task but when I run the script, I get the error message: "Set-Mailbox: A parameter cannot be found that matches parameter name 'WindowsEmailAddress'."

 

I also tried -EmailAddresses but still not recognizing...This is the script:

Connect-ExchangeOnline
Set-Mailbox random.dude -WindowsEmailAddress Email address removed

Can you please tell me if I miss a module or anything? 
I would really appreciate! :)

@raphi_1303 

 

That's really strange. The WindowsEmailAddress is such an old parameter that even if you had an older module (or the on-prem module), you should still see it.

 

After running Connect-ExchangeOnline, get the temporary name of the imported Exchange Online module using:

 

Get-Module -Name tmp_*

 

Then, check for known instances of the Set-Mailbox command using:

Get-Command -All Set-Mailbox

 

You should find just one reference, with the "Source" column value being that of the temporary module from the first command (i.e. it'll look something like "tmp_dgzmuyzr.zi3", though the actual value changes with every new Exchange connection.)

 

If you have more than one module then that may offer some clues on why you're getting that error.

 

If you only see just one result and it's the temporary Exchange module then you can run the following to see if the WindowsEmailAddress parameter is listed. If it is, then I really have no idea what is going on in your case.

 

It should be listed right at the end of the list:

 

(Get-Command Set-Mailbox -ShowCommandInfo).ParameterSets.Parameters.Name | Sort-Object

 

Cheers,

Lain

Don't use the Preview module, or at least make sure to read the release notes before doing so :)
In other words, you need to connect via:

Connect-ExchangeOnline -UseRPSSession