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
Windows Deployment with the Next Generation of Windows Autopilot
Microsoft's latest update to Windows Autopilot brings significant enhancements to the deployment process of Windows devices, catering to the needs...
Shrink PowerPoint files
Need to reduce the size of your PowerPoint file that contain a large number of pictures. Give this a try...
Setting the exchange online max send and receive size
Quick post today around setting exchange online max send and receive size. It can be set using the GUI in...
How to find your Microsoft Exchange build number
When documenting your environment, it’s important to keep track of the build number of your Exchange server. To get the...
Micrsoft Defender for Endpoints
We use Microsoft Defender for endpoints on our physical workstations. I'm now looking at it for our servers. The servers...
Sync Active directory user data with SharePoint
If you want to sync standard common attributes from active directory to sharepoint. Its easy, AD sync to Azure AD...