
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
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...
Microsoft graph API to access sharepoint
Recently I've had to setup a few different app registration using Azure AD to access sharepoint sites. Once you get...
SQL upgrades
We have a few SQL servers that need to be upgraded before they go end of life. We are looking...
How to manage the local administrators group on Azure AD joined devices
After a device is deployed likely using autopilot, sometime you have a need to add an AzureAD user to the...
Azure AD and Windows hello for business, SSO for on-premises resources
We disabled WFB when we first rolled out autopilot because we are not ready to deploy and support passwordless at...