Select-EntraGroupIdsUserIsMemberOf

Selects the groups that a user is a member of.

Syntax

Select-EntraGroupIdsUserIsMemberOf
      -ObjectId <String>
      -GroupIdsForMembershipCheck <GroupIdsForMembershipCheck>
      [<CommonParameters>]

Description

The Select-EntraGroupIdsUserIsMemberOf cmdlet selects the groups that a user is a member of in Microsoft Entra ID.

Examples

Example 1: Get the group membership of a group for a user

Connect-Entra -Scopes 'Application.Read.All'
$myGroup = Get-EntraGroup -Filter "DisplayName eq '<Group-DisplayName>'"
$UserId = 'SawyerM@contoso.com'
$groups = New-Object Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck
$groups.GroupIds = $myGroup.Id
Select-EntraGroupIdsUserIsMemberOf -ObjectId 'SawyerM@contoso.com' -GroupIdsForMembershipCheck $groups

aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb

This example retrieves the group membership of a group for a user.

  • -ObjectId parameter specifies the object Id of a user(as a UserPrincipalName or ObjectId).
  • -GroupIdsForMembershipCheck parameter specifies the group Object Ids.

Parameters

-GroupIdsForMembershipCheck

Specifies an array of group object IDs.

Type:GroupIdsForMembershipCheck
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ObjectId

Specifies the ID of a user (as a UserPrincipalName or ObjectId) in Microsoft Entra ID.

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