
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 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...
Recover Microsoft forms from old users
Microsoft forms are a great way to collect data from the user. However, what happens when the user leaves the...
Creating a document management system with SharePoint
Searching for documents can be a cumbersome and time-consuming task, especially if there is no proper system in place for...
Internal certificates for desktop phones
We are looking at a new cloud based phone system. Most use Poly or Yealink phones, we use 802.1x on...
Intune certificate connector
upgrading to certificate connector 6.2 that is required in Sept 2022, has broke our NDES for intune. I'm collecting all...