Get-EntraUserGroup

Retrieves the list of groups a user belongs to.

Syntax

Get-EntraUserGroup
   -UserId <String>
   [-All]
   [-Top <Int32>]
   [-Property <String[]>]
   [<CommonParameters>]
Get-EntraUserGroup
   -UserId <String>
   -GroupId <String>
   [-Property <String[]>]
   [<CommonParameters>]

Description

The Get-EntraUserGroup cmdlet retrieves a list of groups to which a user belongs.

Examples

Example 1: Get a list of groups to which a specific user belongs

Connect-Entra -Scopes 'GroupMember.Read.All', 'Group.Read.All', 'Directory.Read.All'
Get-EntraUserGroup -UserId 'SawyerM@contoso.com'

DisplayName                Id                                   MailNickname        Description               GroupTypes
-----------                --                                   ------------        -----------               ----------
Contoso Marketing          hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq ContosoMarketing    Contoso Marketing         {Unified}
Mark 8 Project Team        pppppppp-4444-0000-8888-yyyyyyyyyyyy  Mark8ProjectTeam    Mark 8 Project Team       {Unified}
Leadership                 tttttttt-0000-3333-9999-mmmmmmmmmmmm  Leadership          Leadership                {Unified}
Sales and Marketing        qqqqqqqq-5555-0000-1111-hhhhhhhhhhhh  SalesAndMarketing   Sales and Marketing       {Unified}
Retail                     aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb  Retail              Retail                    {Unified}

This cmdlet retrieves a list of groups to which a specific user belongs.

Example 2: Get a list of groups to which a specific user belongs using the All parameter

Connect-Entra -Scopes 'GroupMember.Read.All', 'Group.Read.All', 'Directory.Read.All'
Get-EntraUserGroup -UserId 'SawyerM@contoso.com' -All

DisplayName                Id                                   MailNickname        Description               GroupTypes
-----------                --                                   ------------        -----------               ----------
Contoso Marketing          hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq ContosoMarketing    Contoso Marketing         {Unified}
Mark 8 Project Team        pppppppp-4444-0000-8888-yyyyyyyyyyyy  Mark8ProjectTeam    Mark 8 Project Team       {Unified}
Leadership                 tttttttt-0000-3333-9999-mmmmmmmmmmmm  Leadership          Leadership                {Unified}
Sales and Marketing        qqqqqqqq-5555-0000-1111-hhhhhhhhhhhh  SalesAndMarketing   Sales and Marketing       {Unified}
Retail                     aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb  Retail              Retail                    {Unified}

This cmdlet retrieves a list of groups to which a specific user belongs using the All parameter.

Example 3: Get a group to which a specific user belongs

Connect-Entra -Scopes 'GroupMember.Read.All', 'Group.Read.All', 'Directory.Read.All'
Get-EntraUserGroup -UserId 'SawyerM@contoso.com' -Top 1

DisplayName                Id                                   MailNickname        Description               GroupTypes
-----------                --                                   ------------        -----------               ----------
Contoso Marketing          hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq ContosoMarketing    Contoso Marketing         {Unified}

This cmdlet retrieves a group to which a specific user belongs.

Example 4: Get a list of groups to which a specific user belongs using the group ID parameter

Connect-Entra -Scopes 'GroupMember.Read.All', 'Group.Read.All', 'Directory.Read.All'
$group = Get-EntraGroup -Filter "DisplayName eq 'Contoso Marketing'"
Get-EntraUserGroup -UserId 'SawyerM@contoso.com' -GroupId $group.Id

DisplayName                Id                                   MailNickname        Description               GroupTypes
-----------                --                                   ------------        -----------               ----------
Contoso Marketing          hhhhhhhh-3333-5555-3333-qqqqqqqqqqqq ContosoMarketing    Contoso Marketing         {Unified}

This cmdlet retrieves a list of groups to which a specific user belongs using the group ID parameter.

  • -GroupId parameter specifies the group ID.

Parameters

-All

List all pages.

Type:System.Management.Automation.SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-GroupId

The unique ID of the group.

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

-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

-Top

The maximum number of groups a user belongs to.

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

Outputs

System.Object