
powershell script to update all UPN in a domain
I’m setting up our forest to access office 365. Part of the setup process is to make sure you have UPN set for all users. Our active directory forest has multiple domains each with their own DNS name space. I chose to use one UPN suffix for the entire forest.
I tried to get the script to run for all users in the forest but in the end I had to update the script with the domains and run it once for each.
Replace domain1.com with your AD domain name.
$users = Get-ADUser -filter * -Server domain1.com -resultsetsize $null
foreach($user in $users)
{
$UPN = "$($user.sAMAccountName)@domain1.com"
# Write-Host "Setting " $UPN
$user | Set-ADUser -UserPrincipalName $UPN
}
Hope this helps someone. 🙂
More Stories
How to configuration SMB3 and encryption
We have not enforced SMB3 and encryption, but have now started a SOX review and need data copied between servers...
Windows and SQL editions comparison
Capturing data on the limits of both windows server and SQL based on the edition for quick reference. Comparison of...
Enable passwordless security key sign-in to on-premises resources by using Azure AD
As we transition to Azure AD computers and leave domain joined PCs behind. Most of our data and applications are...
windows update for business and intune
We are having issues with machines not patching even with the Intune policies set. I'm documenting different post I've found...
Enabled the Lock Screen for inactive users
Quick link from Twitter, don’t want to lose the link https://twitter.com/anoopmannur/status/1497256566206181376?s=21 https://www.anoopcnair.com/set-automatic-lock-screen-for-inactive-device-intune/