ITGURU Posted December 30, 2023 Posted December 30, 2023 having run local exchange for years and having the email address format different to the username, now that I have moved fully to 365. how can i automate the local UPN to change to the same format forename.surname@ as all other users when it syncs to 365 via azure AD connect?
kevin_lane Posted December 31, 2023 Posted December 31, 2023 Use something like salamander this takes care of everything 2
snagrat Posted December 31, 2023 Posted December 31, 2023 Assuming the Email Address field is set, and you want the email address to become the UPN, then a simply powershell script will do this. I have one somewhere but ChatGPT came up with this # Import Active Directory module Import-Module ActiveDirectory # Get all users from Active Directory $users = Get-ADUser -Filter * # Loop through each user and set UPN to match email attribute foreach ($user in $users) { $email = $user.EmailAddress $currentUPN = $user.UserPrincipalName $domain = "yourdomain.com" # Change this to your domain if ($email -ne $null) { $newUPN = $email if ($currentUPN -ne $newUPN) { Set-ADUser -Identity $user -UserPrincipalName $newUPN -Server $env:USERDNSDOMAIN Write-Host "Changed UPN for $($user.Name) to $newUPN" } else { Write-Host "UPN for $($user.Name) is already set to $newUPN" } } else { Write-Host "No email found for $($user.Name)" } }
3s-gtech Posted December 31, 2023 Posted December 31, 2023 ADModify.NET may be able to do it for you, ancient as it is. Still does a lot of bulk work for me.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now