logo
search
Others

How to Export Microsoft 365 User and Manager Details to CSV

WPS Content ManagerWPS Content Manager Sep 28, 2026 868 views

Question details

An administrator needs to generate a CSV report containing manager information for all licensed Microsoft 365 users.

How to Export Microsoft 365 User and Manager Details to CSV
Product
Microsoft 365
Device & OS
not provided
Scenario
Generating an administrative hierarchy report containing licensed users and their assigned managers in the organization.
Observed behavior
Administrators need a programmatic method to retrieve user details, query their respective manager's information, and compile the combined data into a CSV format without throwing errors for unassigned fields.
Before you start

Ensure you have the Microsoft Graph PowerShell module installed and that your administrator account has the Directory.Read.All permission in Microsoft Entra ID.

Solution 1Recommended

Use Microsoft Graph PowerShell (Recommended)

Microsoft Graph PowerShell is the modern, supported standard for querying Microsoft Entra ID data, replacing legacy AzureAD cmdlets.

This method queries the Microsoft Graph API to securely retrieve licensed users and their corresponding managers, compiling them into a single report.

1
Connect to Microsoft Graph

Open your PowerShell console as an administrator and run `Connect-MgGraph -Scopes 'User.Read.All'` to authenticate with your tenant.

2
Retrieve licensed users

Fetch active licensed users by running a query like `Get-MgUser -Filter "assignedLicenses/$count ge 1" -ConsistencyLevel eventual -All`.

3
Query manager details

Set up a loop to iterate through each user. Inside the loop, use `Get-MgUserManager -UserId $user.Id` to retrieve the manager's display name and email address.

4
Compile and Export to CSV

Create a custom PSObject containing the user's name, email, department, and their manager's details. Finally, pipe the collected objects to `Export-Csv -Path 'C:\Reports\UserManagers.csv' -NoTypeInformation`.

Use Microsoft Graph PowerShell (Recommended)
Best Practice: Always wrap your manager query in a Try-Catch block. Not all users (such as the CEO or external guests) will have a manager assigned, and handling this gracefully prevents the script from throwing red API errors.
Free Microsoft Office alternative

Easily Open and Analyze Your CSV Reports with WPS Office

After exporting your Microsoft 365 user and manager details via PowerShell, you will need a robust spreadsheet tool to analyze the data. WPS Office is a free, lightweight, and highly compatible alternative to Microsoft Office, offering familiar tools for data analysis without the premium subscription costs.

  1. 1. Launch WPS Spreadsheets: Open WPS Office on your desktop and click on the Spreadsheets module.
  2. 2. Open the CSV File: Navigate to Menu > Open, locate the folder where your PowerShell script saved the 'UserManagers.csv' report, and select it.
  3. 3. Analyze the Data: Use the Data tab to apply filters, sort by department, or format the manager hierarchy columns for easy reading and presentation.
100% compatible with Microsoft Excel CSV and XLSX file formatsFree, lightweight, and fast-loading for large administrative data reportsFamiliar UI that requires zero learning curve for seamless migrationPowerful data filtering and pivot tables for analyzing manager hierarchies
microsoft office alternative - wps office

Frequently Asked Questions

Why is the manager field blank or causing errors for some users?

The manager property is not automatically populated in Microsoft 365; it must be manually assigned in Microsoft Entra ID or synchronized from an on-premises Active Directory. If a user has no assigned manager, the Graph API will return an error unless you handle it with a Try-Catch block in your script.

Can I include the user's department in the same CSV?

Yes. When querying the user object, ensure you select the 'Department' property alongside the DisplayName and UserPrincipalName. You can then append it to your custom PowerShell object before exporting.

Is the AzureAD PowerShell module still supported?

No, Microsoft has officially retired the AzureAD, AzureADPreview, and MSOnline modules. It is strongly recommended to update all automation scripts to use Microsoft Graph PowerShell to ensure ongoing functionality.