Posted on January 29, 2019 by adminAD Connect Setup How to sync on-premises Active Directory to Azure Active Directory with Azure AD Connect? $LocalUsers = Get-ADUser -Filter {UserPrincipalName -like ‘*trollethugo.local’} -Properties userPrincipalName -ResultSetSize $null $LocalUsers | foreach {$newUpn = $_.UserPrincipalName.Replace(“trollethugo.local”,”trollethugo.se”); $_ | Set-ADUser -UserPrincipalName $newUpn}