Powershell - smtp_proxyaddresses_change.ps1

Example on replacing SMTP proxyAddresses with sAMAccountName + hardcoded domain:

Import-Module ActiveDirectory
$users = Get-ADUser -Filter *

foreach ($user in $users) {
    $email = $user.samaccountname + '@domainName.com'
    $newemail = "SMTP:" + $email
    Set-ADUser $user -Add @{proxyAddresses = ($newemail) }
}

Sources:

  • https://community.spiceworks.com/topic/410677-office-365-w-ad-sync-primary-email-address-woes