Get-AzureADUser Company Name

eli sorow 46 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 Security | Microsoft Entra | Microsoft Entra ID
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 46 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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.