Fixing Primary Email Address with Azure AD Connect

I had a ticket come across my desk today for a user who's email was coming from her onmicrosoft.com address instead of what her email address should be. Upon looking, I found that her Primary Email Address was indeed wrong. The client's using Azure AD Connect, so the primary email address syncs up from the mail field in ActiveDirectory, which was correctly set.

If you've run into this issue, you know that you can't change the primary email address in Office365's web portal. Conveniently, you can still change it from PowerShell:

$user = Get-Mailbox someusername
Set-Mailbox -Identity $user.ExchangeGuid.Guid -WindowsEmailAddress someusername@domain.com

Those simple 2 lines are all you need to change the primary email account.