Export Office 365 User Manager and Direct Reports Using PowerShell

The objective of a Microsoft 365 Admin is to keep the data up to date. Retrieving the manager’s information and ensuring its correctness is one of them. The manager data is the significant component to create the organization chart. As various services depend on this data, it is necessary to regularly verify the manager and direct report information.   

 

How to View the Azure AD Users with Manager Details: 

Using UI: You can view the Office 365 users’ manager in the Azure AD portal. Go to Azure AD ‘Dashboard’. Select the ‘Users’ and click on the user. In the profile, you can view the ‘Manager’ under ‘Job Info’. However, getting a manager report in the Azure AD is an effort-consuming task as you can see the result of one user at a time. 

Using PowerShell: You can use PowerShell cmdlet ‘Get-AzureADUserManager’ to get the manager information of the users. You can use the ‘Get-AzureAdUserDirectReport’ cmdlet to get the direct reports of the manager. But these cmdlets don’t contain the user data attributes. Each time you will need to run the Get-AzureADUser’ cmdlet to get the user information. It isn’t easy when you want to generate different reports to meet your business requirements.

As usual, it is not that simple to quickly get a manager report from Microsoft 365 Admin Center. The administrators need a powerful Microsoft 365 reporting tool to get both managers and direct reports details seamlessly. Considering these difficulties, we have created a multipurpose script, GetM365ManagerAndDirectReports.ps1′. We can discuss the script’s functionalities in detail now. 

 

Script Highlights: 
  • Generates 10+ different manager reports to view the managers and direct reports status.  
  • Automatically installs the Azure AD module upon your confirmation when it is not available in your machine. 
  • Shows list of all Azure AD users and their manager.  
  • List of all Office 365 users with no manager. 
  • Allows specifying user departments to get their manager details. 
  • You can get the direct reports of the Office 365 managers. 
  • Supports both MFA and Non-MFA accounts.    
  • Exports the report in CSV format.  
  • Scheduler-friendly. You can automate the report generation upon passing credentials as parameters. 

 

Download Script: GetM365ManagerAndDirectReports.ps1

 

Office 365 User Manager Report – Script Execution Overview 

The administrators need different types of managers’ reports to address business requirements and management activities. You can run the script with a simple execution format to get various user manager reports. Following manager reports that contain detailed attributes of both users and managers.    

You can filter  ‘DisabledUsers’ and  ‘UnlicensedUsers’ using the switch params which are discussed in the ‘More use cases’ section. These filters help to unlock the script’s full potential. We have explained the steps to supply inputs and generating reports below.   

 

Get Office 365 Users and Their Manager: 

The Office 365 users are assigned to a manager while processing their organization profile. The manager may change based on the user role and other factors. The administrators monitor the users’ manager info to ensure the profile is updated correctly. Using our script, you can get the list of users and their manager’s name along with the significant attributes.  

The exported manager report contains both users’ and managers’ information like Name, UPN, Department, Account Status and License Status.

Sample Output: 

Get Office 365 users with manger

 

Get Office 365 Users Without Manager: 

There are specific business sectors where the users don’t have a manager to report. These users can belong to any department or user category (like guest). They don’t need managers as their role in the organization is distinct. Using our script, the administrators can quickly identify users who don’t have a manager and verify their accounts. The switch param ‘UsersWithoutManager’ is used to get the users without the manager report.  

The report has essential user account attributes that help the administrator decide the necessity to set up managers for them. 

Sample Output: 

Get all Azure AD users without manager

 

Get Office 365 Managers and Direct Reports: 

Manager and their direct report data is a significant report frequently requested to Admins. This data is used to construct the organization chart effectively. Using the ‘DirectReports’ switch, you can get managers and their direct reports information in a Jiffy.  

The format shown above provides a list of managers and their direct reports. Also, the report shows how many direct reports the managers have, along with the direct reports names and UPNs.

Sample Output: 

Get Office 365 manager and their direct reports

 

Find Office 365 Users’ Manager by Department: 

Department managers are the driving force behind a department’s growth through achieving high levels of productivity. The administrators confirm that the department managers are available to deliver business updates. When your tenant has a large user population, you can generate manager reports based on department filters to save time.   

Using the ‘Department’ parameter, you can view the users available in the specific departments and their manager details.  

Specifying the list of departments enclosed with quotes and separated with a comma is essential. Mention the departments of the users in the input to know their manager’s data. 

Sample Output: 

Find Office 365 user department managers information

 

Get Manager Detail of Disabled Users:  

The admin regulates the users’ off-boarding activities. These user accounts are retained as disabled accounts to preserve the data for the compliance requirements.  

You can use the ‘DisabledUsers’ param to generate disabled users’ manager reports.   

The report has only disabled users and their manager information.   

 

Get Office 365 Unlicensed Users and Their Managers: 

Every Office 365 user must have at least one license to continue their work. It’s the administrators’ responsibility to make sure all users are licensed properly. The administrator assigns proper licenses to the user after confirming with the manager. Using the unlicensed users’ manager report, the administrator identifies the manager to get the license suggestions for these users. 

Using the ‘UnlicensedUsers’ param, you can get only unlicensed users and their managers. 

 

Scheduling Office365 Users’ Manager and Direct Reports: 

Based on organization functionalities, you can schedule the PowerShell script to monitor the daily or periodic status of the user and manager report. To schedule the execution, you can use both MFA and non-MFA accounts.  

To use the non-MFA admin accounts, try the format below.   

If the admin account has MFA, then they cannot use it directly for scheduling. Instead, you have to disable MFA based on the Conditional Access Policy to make it work. 

 

Office 365 User Manager Report – Additional Use Cases: 

You can append the ‘-Disabled Users’ or ‘-UnlicensedUsers’ or both params with other parameters to filter the results further. Below are some examples to granularly filter the results. 

  • Get manager info of disabled users who don’t have an Office 365 license. 

 

  • View direct reports of disabled managers who don’t have an Office 365 license. 

 

  • List disabled users who don’t have an Office 365 license and a manager. 

 

  • Get users from different departments who don’t have a manager. 

 

  • Get direct reports of managers in a department. 

 

We hope this script helps to get the users’ manager report and managers’ direct reports effectively. If there is still something unclear to you, please leave a comment, and we will address your questions.