Wednesday, January 9, 2019

Office 365 Migration Issue

While migrating a client to O365 Exchange Online, I encountered an issue with mailboxes not syncing. After some quick troubleshooting it was determined they lacked the "UserName@DomainName.mail.onmicrosoft.com" proxy address, required for the sync.

Below is the PowerShell script I wrote to add a proxyAddress to all users in the specified OU:

Import-Module ActiveDirectory 
$searchbase = "OU=OrgUnit,DC=DomainName,DC=Suffix"
$newdomain = '@DomainName.mail.onmicrosoft.com'
$users = Get-ADUser -SearchBase $searchbase -Filter * -Properties SamAccountName
 
ForEach ($user in $users) {
    $SamAccountName = $user.SamAccountName
    Set-ADUser -Identity "$SamAccountName" -Add @{
        'proxyAddresses' = "smtp:$SamAccountName‎" + $newdomain
    }
    Write-Host "Adding proxyAddress to $SamAccountName"
}

No comments:

Post a Comment