After a bit more working with PowerShell and Office365 (which is really powerful by the way), I decided that whilst I’d reset my primary email address for the one and only admin user in my domain (In this post), I still wanted to change my main login name (i.e. my UPN). By this I mean I wanted to change the suffix on my login (i.e. from email@example.com to firstname.lastname@example.org).
As you cant change certain information on the account your logged in to, and as I only have one account, I decided to go down the powershell route again – and I have to say it was well worth it!
The use of powershell with Office365 is really impressive – and whilst I’m definitely new to powershell its stuff like this that really gets me interested. So, enough with the gushing and onto how its done:
Changing the UPN in Office365 remotely
The first steps are much the same as in the previous post, but importantly you must download and install the Office365 module for PowerShell. There’s some instructions here (dont worry about all the SSO stuff, you just need the module installed). Just one last note – I got most of this solution from the Office365 community at: http://community.office365.com/en-us/f/148/p/4303/17035.aspx.
So fire up PowerShell and off we go:
1. > $LiveCred = Get-Credential
2. Now you need to enter your office365 credentials in the popup
3. > $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
3. > Import-PSSession $Session (note that if this command fails, you may have to use “Set-ExecutionPolicy RemoteSigned” first, but please make sure you understand the implications of this first).
4. > Connect-MsolService
5. > Set-MsolUserPrincipalName -NewUserPrincipalName [New Name] -UserPrincipalName [Old Name]
Note: [New Name] is email@example.com and [Old Name] is firstname.lastname@example.org
And then you’re done (big thanks to Allan Xu MS Moderator!!). You can login using your proper domain name