Azure AD , Export list of users with script of Powershell

GuestGuivenchi 105 Reputation points
2024-01-03T17:15:21.7733333+00:00

Good day,

I manage Azure AD.

I want to download a list of all users with specific properties.

How can I get the data I need?

Data:

"Manager" "Company Name"

Someone has a script or the property name that I need use in Powershell.

Thank you.

Windows for business Windows Server User experience PowerShell
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Givary-MSFT 35,621 Reputation points Microsoft Employee Moderator
    2024-01-04T06:16:48.53+00:00

    @GuestGuivenchi Thank you for reaching out to us, As I understand you are looking for PowerShell script to fetch these details Manager & Company Name for the users defined in Azure AD.

    Try the below script to achieve the desired outcome, tested the same and it works as expected.

    $userlist= Get-AzureADUser -All $true
    $output = @()
    foreach( $item in $userlist){
        $mgname=Get-AzureADUserManager -ObjectId $item.ObjectId 
        $output += [pscustomobject]@{
            "Display Name" = $item.DisplayName
            "Company Name" = $item.companyName
            "Manager Name" = $mgname.DisplayName
        }
    }
    $output | Export-Csv C:\Test\sampleuser_2.csv
    

    Let me know if you have any further questions, feel free to post back.

    Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.