Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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

April 18, 2022 Active DirectoryAzureMicrosoft 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 appeared 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, UserPrincipalName value is stored 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 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 IdFix 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.

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, Intune. It is UserPrincipalName that 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
4
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

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

Installing Language Pack in Windows 10/11 with PowerShell

September 15, 2023

Leave a Comment Cancel Reply

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

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

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
  • Deploy PowerShell Active Directory Module without Installing RSAT
  • Configuring Proxy Settings on Windows Using Group Policy Preferences
Footer Logo

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


Back To Top