Wednesday, May 22, 2013

How to Change a Users Primary Email Address in Office 365

Microsoft's Office 365 is still pretty new and some things that seem like they should be easy and obvious are not. While Office 365 administrative interface for Exchange may seem limited, virtually everything that can be done in Exchange can be done in Office 365, it's just that some functions may require Windows PowerShell.

If you haven't already setup Windows PowerShell to work with Office 365, please see: How to Install and Configure PowerShell for Office 365 in Windows 8.

Keep in mind, I've cleared the PowerShell windows after each command for clarity. Yours, if left uncleared, will scroll when the window becomes full.

Run the Windows Azure Active Directory Module for Windows PowerShell as administrator

To run the scripts needed to change a user’s primary email address we must first set the script execution policy. At the PowerShell prompt type the following cmdlet (PowerShell command):


The execution policy needs to be RemoteSigned. RemoteSigned allows only downloaded scripts signed by a trusted publisher to be run. If Get-ExecutionPolicy doesn't return RemoteSigned, it must be changed by typing the following cmdlet and entering a "y" when prompted:

Set-ExecutionPolicy RemoteSigned

Now Get-ExecutionPolicy returns RemoteSigned

Next we need to provide Office 365 with administrative credentials to be able to make changes. We're going to assign our credentials to the variable $MSCred...

$MSCred = Get-Credential

...and PowerShell prompts for an Office 365 account with administrative permissions.

After entering the credentials of a Office 365 administrator account and clicking OK, we need to open a connection to the Office 365 servers. The following command opens a connection, passes on our credentials, and assigns the variable $Session to our session.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $MSCred -Authentication Basic -AllowRedirection

Once the connection is open we need to import the commands for the Exchange Server shell.

Import-PSSession $Session

At this point we are ready to issue commands to Office 365. The following command sets a user's primary email address from the current address to the desired address without changing the username. Replace and to the appropriate email addresses:

Set-Mailbox -identity -WindowsEmailAddress

The Office 365 online administrative interface should show the new email address as the primary.

Last we should close the session. If we do not close the session, it will remain available until it times out.

Remove-PSSession $Session

More Exchange cmdlets can be found at

No comments:

Post a Comment