Get-EntraUserManager

Gets the manager of a user.

Syntax

Get-EntraUserManager
   -UserId <String>
   [-Property <String[]>]
   [<CommonParameters>]

Description

The Get-EntraUserManager cmdlet gets the manager of a user in Microsoft Entra ID. Specify UserId parameter to get the specific manager of user.

Examples

Example 1: Get the manager of a user

Connect-Entra -Scopes 'User.Read.All'
Get-EntraUserManager -UserId 'SawyerM@contoso.com'

DeletedDateTime                 :
Id                              : 00aa00aa-bb11-cc22-dd33-44ee44ee44ee
@odata.context                  : https://graph.microsoft.com/beta/$metadata#directoryObjects/$entity
@odata.type                     : #microsoft.graph.user
accountEnabled                  : True
businessPhones                  : {+1 858 555 0109}
city                            : San Diego
createdDateTime                 : 2023-07-07T14:18:05Z
country                         : United States
department                      : Sales & Marketing
displayName                     : Sawyer Miller

This example demonstrates how to retrieve the manager of a specific user.

  • -UserId Parameter specifies UserId or User Principal Name of User.

Example 2: Retrieve users without managers

Connect-Entra -Scopes 'User.Read.All'
$allUsers = Get-EntraUser -All
$usersWithoutManagers = foreach ($user in $allUsers) {
    $manager = Get-EntraUserManager -ObjectId $user.Id -ErrorAction SilentlyContinue
    if (-not $manager) {
        [pscustomobject]@{
            Id               = $user.Id
            DisplayName      = $user.DisplayName
            UserPrincipalName = $user.UserPrincipalName
        }
    }
}
$usersWithoutManagers | Format-Table Id, DisplayName, UserPrincipalName -AutoSize

Id                                   DisplayName     UserPrincipalName
--                                   -----------     -----------------
cccccccc-2222-3333-4444-dddddddddddd  New User       NewUser@tenant.com
bbbbbbbb-1111-2222-3333-cccccccccccc  Sawyer Miller  SawyerM@contoso.com

This example demonstrates how to retrieve users without managers.

Parameters

-Property

Specifies properties to be returned.

Type:System.String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UserId

The unique identifier of a user in Microsoft Entra ID (User Principal Name or UserId).

Type:System.String
Aliases:ObjectId
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False