Get-AzureADUser Company Name

eli sorow 41 Reputation points
2020-08-05T14:21:15.137+00:00

Hi all,
in order to have an aduser list sorted by company name, i tried
Get-AzureADUser -All $true | select UserPrincipalName -ExpandProperty CompanyName
Get-AzureADUser -All $true | Select-Object -Property CompanyName

both commands give only a list of the companies

Get-AzureADUser -All $true | select UserPrincipalName alone gives the list of ad users
and with the -ExpandProperty CompanyName we have only the list of the companies without the users

any idea how to display both UPN and company name ?

it seems simple but honestly after several hours and hundreds of powershell commands (true, true) i didn t figure it out .

sincere thanks for any help

regards

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,452 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sircana, Matteo 76 Reputation points
    2020-08-05T15:20:28.777+00:00

    Hi @eli sorow ,

    you can try this:

    Get-AzureADUser -All $true | Select-Object -Property CompanyName, UserPrincipalName

    After the -Property parameter you can add the properties to show separated by comma.

    Then at the command end you can add | Sort-Object -Property CompanyName to sort by CompanyName

    0 comments No comments

  2. eli sorow 41 Reputation points
    2020-08-06T08:44:19.44+00:00

    Hi @Sircana, Matteo

    it was so close but still so far !
    thank you so much,

    any idea to add "Select -ExpandProperty AssignedLicenses in this ps command

    the goal is to have a list of the AD users with company name and licensetype assigned.

    thanks again for ur help.
    Eli