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' |
Select-Object Id, displayName, userPrincipalName, createdDateTime, accountEnabled, userType |
Format-Table -AutoSize
id displayName userPrincipalName createdDateTime accountEnabled userType
-- ----------- ----------------- --------------- -------------- --------
00aa00aa-bb11-cc22-dd33-44ee44ee44ee Patti Fernandez PattiF@Contoso.com 10/7/2024 12:32:01 AM True Member
This example demonstrates how to retrieve the manager of a specific user.
-UserId
Parameter specifies UserId or User Principal Name of User.
Example 2: List users without a manager
Connect-Entra -Scopes 'User.Read.All'
$allUsers = Get-EntraUser -All
$usersWithoutManagers = foreach ($user in $allUsers) {
$manager = Get-EntraUserManager -UserId $user.Id -ErrorAction SilentlyContinue
if (-not $manager) {
[PSCustomObject]@{
Id = $user.Id
DisplayName = $user.DisplayName
UserPrincipalName = $user.UserPrincipalName
UserType = $user.userType
AccountEnabled = $user.accountEnabled
CreatedDateTime = $user.createdDateTime
}
}
}
$usersWithoutManagers | Format-Table Id, DisplayName, UserPrincipalName, CreatedDateTime, UserType, AccountEnabled -AutoSize
Id DisplayName UserPrincipalName CreatedDateTime UserType AccountEnabled
-- ----------- ----------------- --------------- -------- --------------
cccccccc-2222-3333-4444-dddddddddddd New User NewUser@tenant.com 10/7/2024 2:24:26 PM Member True
bbbbbbbb-1111-2222-3333-cccccccccccc Sawyer Miller SawyerM@contoso.com 10/7/2024 12:33:36 AM Member True
This example demonstrates how to retrieve users without managers.
Parameters
-Property
Specifies properties to be returned.
Type: | System.String[] |
Aliases: | Select |
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 |