Output extension9 and Name for all users in specified OU in AD via powershell script

Ozz 21 Reputation points
2021-06-22T08:32:53.927+00:00
$ou = "OU=Whatever,DC=MYDomain,DC=local"
 Get-ADUser -Filter * -SearchBase $ou -Properties extensionattribute9 | Select-Object -ExpandProperty extensionattribute9

Hello, is someone able to help me with displaying extension attribute9 and next to it the users display name for everyone in the specified OU. The above code displays extension9 but I need help with getting it to also display the canonical name or display name also.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,930 questions
Microsoft 365 Publishing
Microsoft 365 Publishing
Microsoft 365: Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line. Publishing: The process of preparing, producing, and releasing content for distribution or sale.
598 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,660 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 95,836 Reputation points MVP
    2021-06-22T08:56:52.33+00:00

    Simply add the desired properties, and drop the -ExpandProperty switch.

    Get-ADUser -Filter * -SearchBase $ou -Properties DisplayName,extensionattribute9 | Select-Object DisplayName,extensionattribute9
    
    1 person found this answer helpful.
    0 comments No comments