How to get an Active Directory user's display name using PowerShell

Retrieving the display name of Active Directory (AD) users is a common administrative task for IT teams. It is what most users and applications see, rather than technical identifiers like sAMAccountName or DistinguishedName (DN), and is widely used in corporate address books, email clients, audit reports, and identity management systems. When managing user accounts in larger organizations, the ability to quickly look up or export display names reduces errors and saves time. Although PowerShell offers a dependable method, GUI-based tools like ManageEngine ADManager Plus make things easier by providing bulk management features, export options, and built-in reports.

Getting AD user display name: PowerShell vs ADManager Plus

Below is a comparison of how to get an AD user's display name using Windows PowerShell and ManageEngine ADManager Plus.

Windows PowerShell

Prerequisites

Open Windows PowerShell and import the Active Directory module:

Import-Module ActiveDirectory

Getting an AD user's display name

To get the display name of a known user, specify the user's identity (e.g., sAMAccountName, UserPrincipalName, or DistinguishedName) and explicitly request the DisplayName property. Replace "username" with the actual user logon name:

Get-ADUser -Identity "username" -Properties DisplayName | Select-Object DisplayName
ADManager Plus
  1. Navigate to Reports > User Reports > General Reports > All Users.
  2. Select the domain and OU, and click Generate.
  3. To search for a specific user, click the Search icon and enter the user's SAMAccountName or logon name.

Want to edit display names? See how ADManager Plus can help modify AD user attributes.

Example scripts and use cases with display name

Example 1: Get a user's display name by SAM account name

This returns the display name property of the user with the SAM account name "jdoe".

Get-ADUser -Identity "jdoe" -Properties DisplayName | Select-Object DisplayName

Example 2: Get display names for all users

Lists every user in AD with both their logon name and display name.

Get-ADUser -Filter * -Properties DisplayName | Select-Object Name, DisplayName

Example 3: Export all user display names to CSV

Exports the name and display name of all users to a CSV file.

Get-ADUser -Filter * -Properties DisplayName | Select-Object Name, DisplayName | Export-Csv -Path "C:\AllUserDisplayNames.csv" -NoTypeInformation

Example 4: Search AD users by partial or full display name

This helps find users if you only know part of their display name.

Get-ADUser -Filter "DisplayName -like '*John*'" -Properties DisplayName | Select-Object SamAccountName, DisplayName

Example 5: Find a user's logon name by their display name

This searches for users whose display name exactly matches "John Doe".

Get-ADUser -Filter {DisplayName -eq "John Doe"} -Properties SamAccountName | Select-Object SamAccountName, DisplayName

Example 6: Pull properties of AD users via display names

This imports a CSV file containing display names of users and outputs properties like sAMAccountName and email address.

$users = Import-Csv -Path "C:\Path\To\UsersByDisplayName.csv"
foreach ($user in $users) {
$adUser = Get-ADUser -Filter {DisplayName -eq $user.DisplayName} -Properties SamAccountName, DisplayName, EmailAddress, Title
if ($adUser) {
# If multiple users with same display name, return all
foreach ($u in $adUser) {
Write-Output "DisplayName: $($u.DisplayName), SamAccountName: $($u.SamAccountName), Email: $($u.EmailAddress), Title: $($u.Title)"
}
} else {
Write-Output "User with DisplayName '$($user.DisplayName)' not found."
}
}

Supported parameters

The following parameters are useful for retrieving user display names with PowerShell:

Parameter Description
-Identity Specifies the user to query (SAM account name, DN, GUID, or SID)
-Filter Enables filtering by DisplayName or other attributes
-Properties Requests additional properties (like DisplayName) in results
-SearchBase Limits the search to a specific OU or container
-Server Specifies the domain controller to query
-Credential Runs with alternate credentials
-AuthType Selects authentication methods like Negotiate and Basic.

Limitations of using PowerShell scripts to get display names

While powerful, relying solely on PowerShell for extensive user reporting can present challenges:

  • Complexity for non-scripters: Crafting and debugging complex scripts can be time-consuming for administrators less familiar with PowerShell.
  • Lack of centralized reporting: Generating comprehensive PowerShell reports for various AD attributes often requires combining multiple scripts and manual data consolidation.
  • Error handling: Robust error handling needs to be explicitly built into every script.

Benefits of choosing ADManager Plus over PowerShell

ADManager Plus bridges the gap between powerful AD reporting and ease of use. Here's why it's a better choice for many IT teams:

  • No scripts required: Easily generate reports on AD user attributes like display name and more in a few clicks without any scripting.
  • Predefined reports: Access over 200 out-of-the-box reports, saving you significant time.
  • Customizable reports: Create tailored reports with specific attributes and filters to meet your unique auditing and compliance needs.
  • Automated report scheduling: Schedule reports to be generated and delivered automatically to your inbox, ensuring you always have up-to-date information.
  • Delegated reporting: Securely delegate AD reporting tasks to help desk technicians without exposing them to sensitive data or complex PowerShell scripts.

Fetch your AD users' display names today

FAQs

Run the following command to search for display names and include unique identifiers like SamAccountName or DistinguishedName:

Get-ADUser -Filter {DisplayName -eq "John Smith"} -Properties SamAccountName, DistinguishedName |
Select-Object DisplayName, SamAccountName, DistinguishedName

Run this command to fetch display names with group memberships:

Get-ADUser -Filter * -Properties DisplayName |
Select-Object DisplayName, @{Name="Groups";Expression={(Get-ADPrincipalGroupMembership $_ | Select-Object -ExpandProperty Name) -join ","}}

Alternatively, ADManager Plus offers pre-built reports to help you list AD group memberships with users' display names.

ADManager Plus offers features to help you update AD user attributes in bulk, like display names, logon names, and more. This prevents the hassle of repetitive actions and scripting errors.

To bulk update using PowerShell, first prepare a CSV file (e.g., C:\DisplayNames.csv) with SamAccountName and DisplayName columns. Then run:

Import-Csv "C:\DisplayNames.csv" | ForEach-Object {
Set-ADUser -Identity $_.SamAccountName -DisplayName $_.DisplayName
}

Run the following script to find a user’s logon name using their display name:

Get-ADUser -Filter {DisplayName -eq "John Doe"} -Properties SamAccountName | Select-Object SamAccountName, DisplayName
The one-stop solution to Active Directory Management and Reporting
Email Download Link