The Get-MgUserDirectReport cmdlet in Microsoft Graph PowerShell retrieves the list of users who directly report to a specified user. It helps administrators understand reporting hierarchies and manage organizational structures more effectively.
With Get-MgUserDirectReport, administrators can:
This cmdlet eliminates the need to manually check reporting structures through the Microsoft 365 Admin Center.
Before using this cmdlet, connect to Microsoft Graph with the required permissions:
Connect-MgGraph -Scopes "User.Read.All"
Syntax (essential parameters):
Get-MgUserDirectReport -UserId [-ExpandProperty <String[]>] [-Property <String[]>]
You must supply a UserId (UPN or ObjectId) of the manager to retrieve their direct reports.
Get-MgUserDirectReport -UserId "samadmin@7xh7fj.onmicrosoft.com"
This command retrieves a list of users who report directly to Sam Admin.
# Retrieve the direct reports of the user
$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
}
} | Format-Table -AutoSize
} else {
Write-Host "No direct reports found for the specified user."
}
This command fetches the direct reports of Sam Admin, retrieves full details for each, and displays DisplayName and JobTitle.
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