Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Active Directory / Configuring UserPrincipalName and UPN Suffixes in Active Directory

March 11, 2024 Active DirectoryAzure and Microsoft 365PowerShell

Configuring UserPrincipalName and UPN Suffixes in Active Directory

In this article, we’ll look at what UPN (UserPrincipalName) suffixes in Active Directory are, how to add alternative suffixes in an AD forest and change UPN suffixes of Active Directory users with the ADUC console and PowerShell.

UserPrincipalName (UPN) is the user’s logon name in the format of an email address, for example, [email protected] . UPN name doesn’t necessarily have to match the user’s email address. In this case, maxb is the username in an Active Directory domain (user logon name), contoso.com is the UPN suffix. They have a delimiter @ between them.

By default, the DNS name of your AD domain is used as the UPN suffix in Active Directory. For example, a UserPrincipalName in the woshub.local domain looks like this: [email protected].

Do not mix a UserPrincipalName with sAMAccountName being a legacy AD attribute staying there from older times.

If your internal AD DS uses a non-routable domain name (like, mydomain.loc), you won’t be able to verify the domain in Azure (Microsoft 365). To configure synchronization with Azure, you will have to rename your AD domain (it is not always possible) or (much easier) add extra (alternative) UPN suffixes to your AD.

Contents:
  • How to Add Alternative UPN Suffix in Active Directory?
  • Changing the User Principal Name (UPN) in Active Directory

How to Add Alternative UPN Suffix in Active Directory?

In Active Directory, you can add additional (alternative) UPN suffixes using the Active Directory Domains and Trusts graphic console or PowerShell.

Open a PowerShell console and run the Get-ADForest command from the AD PowerShell module. The command below will list all assigned UPN suffixes in the forest:

Get-ADForest | Format-List UPNSuffixes

If the list is empty, it means that you are using a default UPN suffix matching your DNS domain name.

To add an alternative UPN suffix (for example, woshub.com), run this command:

Get-ADForest | Set-ADForest -UPNSuffixes @{add="woshub.com"}

Make sure that the suffix appears in UPNSuffixes:

Get-ADForest | Format-List UPNSuffixes

get all UPNSuffixesin Active Directory

You can add multiple unique UPN suffixes. Usually, it is worth doing if you have users from different organizations (brands) in your domain and you want to use different UPN suffixes for them.
  1. You can also add a UPN suffix using the Active Directory Domains and Trusts console;
  2. Run the domain.msc snap-in;
  3. Open the Active Directory Domains and Trusts properties;
  4. Add a new suffix to the Alternative UPN suffixes box and click Add.

add alternate UPN suffix in AD

Changing the User Principal Name (UPN) in Active Directory

You can display the current value of the UserPrincipalName attribute using the Get-ADUser cmdlet:

Get-ADUser f.martusciello -properties select userprincipalname

powershell- get-aduser userprincipalname

You can change the UPN suffix for your AD users. The easiest way to do it is to change UserPrincipalName in user properties in the ADUC console (dsa.msc).

As you can see, all UPN suffixes of the domain are available in the list. Select the one you want and click OK.

change user UPN suffix using ADUC snap-in

Note that UserPrincipalName in this form consists of two parts: a user name and a UPN suffix. In fact, the UserPrincipalName value is stored as a single AD attribute.

UserPrincipalName - active directory user attribute

When you want to change UPN for multiple users at once, you can select users in the ADUC console and click Properties. Go to the Account tab and change the UPN suffix for all selected users. (If you want to get users from different OUs into a flat list, use the saved queries in the ADUC console.)

How to change multiple users UPN suffix?

But it is easier to use PowerShell to change the user UPN suffix.

To change a UPN suffix for a user, use the Set-ADUser cmdlet with the UserPrincipalName parameter:

Set-ADUser f.martusciello -UserPrincipalName [email protected]

The following PowerShell script allows you to find users with the specific UPN suffix in an OU and change the UserPrincipalName to a new one.

Get-ADUser -Filter {UserPrincipalName -like "*@mydomain.loc"} -SearchBase " OU=Users,OU=Munich,DC=mydomain,DC=loc" |
ForEach-Object {
$UPN = $_.UserPrincipalName.Replace("mydomain.loc","woshub.com")
Set-ADUser $_ -UserPrincipalName $UPN -verbose
}

This PowerShell command allows to find users who have no UserPrincipalName set:

Get-ADUser -LDAPFilter "(!(userPrincipalName=*))" | Select distinguishedName

Microsoft recommends using the Microsoft Office 365 IdFix tool (Directory Synchronization Error Remediation)tool to validate your on-premises Active Directory before syncing to Azure via Azure AD Connect. This can help to identify different problems with user attributes, including UserPrincipalName, proxyAddresses, mail:

 

  • Invalid symbols in AD object names (including leading and trailing spaces);
  • Duplicates;
  • Blank attribute values;
  • Invalid SMTP addresses, MailNickNames;
  • Objects with attribute values that exceed acceptable limits.

 

If you create a new user, you can select an alternate UPN suffix instead of a DNS name of your domain.

set UPN suffix then creating new AD user

If you create users using the New-ADUser PowerShell cmdlet, specify a new UPN suffix with the UserPrincipalName switch:

New-ADUser -Name "Jan Kraus" -GivenName "Jan" -Surname "Kraus" -SamAccountName "j.kraus" -UserPrincipalName [email protected]

Today an issue of UPN suffixes arises if you are going to configure on-premises Active Directory synchronization with Azure AD, Microsoft 365, and Intune. It is UserPrincipalName which is a unique user identifier in Azure.

Historically, many companies have been using non-routable or non-existing DNS names (like *.loc, *.local) for their internal AD domains.

Each AD user that will sync to Azure must be assigned a unique and internet-routable userPrincipalName that matches the domain of your Azure tenant (Microsoft 365).

0 comment
5
Facebook Twitter Google + Pinterest
previous post
Fix: Cannot Open Executable (.EXE) Files on Windows
next post
Get-ADUser: Find Active Directory User Info with PowerShell

Related Reading

Configure NTP Time Source for Active Directory Domain

May 6, 2025

View Windows Update History with PowerShell (CMD)

April 30, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Allowing Ping (ICMP Echo) Responses in Windows Firewall

April 15, 2025

How to Pause (Delay) Update Installation on Windows...

April 11, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Configure Google Chrome Settings with Group Policy
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • How to Find the Source of Account Lockouts in Active Directory
  • How to Disable or Enable USB Drives in Windows using Group Policy
  • Get-ADComputer: Find Computer Properties in Active Directory with PowerShell
  • Configuring Proxy Settings on Windows Using Group Policy Preferences
  • Adding Domain Users to the Local Administrators Group in Windows
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top