Powershell – Change Exchange Alias to Match SamAccountName
Quick Powershell snippet to modify a users Exchange Alias to match the the Active Directory SamAccountName. This came in handy when deploying Airwatch using the {EmailUserName} variables to configure Exchange properties in profiles.
$mboxes = Get-Mailbox -OrganizationalUnit contoso.com/users/sales
foreach ($m in $mboxes) {
$m | Set-Mailbox -Alias $m.SamAccountName
}