The Get-MgUserDirectReport cmdlet is part of the Microsoft Graph PowerShell module and is used to retrieve a list of users who directly report to a specified Microsoft 365 user. This cmdlet helps administrators gain insight into organizational reporting structures and streamline management tasks.
Understanding reporting relationships is crucial for IT administrators, HR teams, and compliance officers. The Get-MgUserDirectReport cmdlet is useful for:
The basic syntax for Get-MgUserDirectReport is:
Get-MgUserDirectReport -UserId <UserID>
This example retrieves the User IDs of all direct reports under a specified manager.
Get-MgUserDirectReport -UserId samadmin@7xh7fj.onmicrosoft.com
To retrieve direct reports' Display Name, Job Title, and Email Address, we first fetch the user IDs and then retrieve their details using Get-MgUser.
$directReports = Get-MgUserDirectReport -UserId "samadmin@7xh7fj.onmicrosoft.com"
# Check if any direct reports are returned
if ($directReports.Count -gt 0) {
# Loop through each direct report and retrieve full user details
$directReports | ForEach-Object {
$userId = $_.Id
$user = Get-MgUser -UserId $userId
[PSCustomObject]@{
DisplayName = $user.DisplayName
JobTitle = $user.JobTitle
UserPrincipalName = $user.UserPrincipalName
Email = $user.Mail
}
} | Format-Table -AutoSize
} else {
Write-Host "No direct reports found for the specified user."
}
If a user has no direct reports, the cmdlet will return an empty result.
No, guest users in Microsoft 365 typically do not have direct reports assigned.
No, Get-MgUserDirectReport is a read-only cmdlet. To modify reporting relationships, use Set-MgUserManager.
Get-MgUserDirectReport
only returns users who have the specified person set as their manager in Azure AD.manager
attribute is not assigned to users — even if they report to that person in practice — the cmdlet will return an empty result.
Get-MgUserDirectReport
are based solely on what's configured in Azure AD.
Tools like SharePoint, Delve, or org chart software may show a different structure unless the manager
attribute is properly maintained in Azure AD.
Error | Cause | Solution |
Request_ResourceNotFound | The user ID provided does not exist. | Ensure the correct UserPrincipalName or Object ID is used. |
NotFound | The user does not have any direct reports. | Verify if the user has subordinates in Azure AD. |
Permission Denied | Insufficient permissions to run the cmdlet. | Ensure your account has User.Read.All and Directory.Read.All permissions. |
The Get-MgUserDirectReport cmdlet is an essential tool for Microsoft 365 administrators to retrieve user reporting relationships efficiently. It helps automate reporting tasks, enables workflow management, and ensures compliance with organizational policies. By utilizing PowerShell scripts, you can quickly fetch and analyze reporting structures to streamline administrative operations.
Start using Get-MgUserDirectReport today to enhance your Microsoft 365 administration!
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex