Edit

Share via


Select-EntraGroupIdsServicePrincipalIsMemberOf

Selects the groups in which a service principal is a member.

Syntax

Default (Default)

Select-EntraGroupIdsServicePrincipalIsMemberOf

    -ServicePrincipalId <String>
    -GroupIdsForMembershipCheck <GroupIdsForMembershipCheck>
    [<CommonParameters>]

Description

The Select-EntraGroupIdsServicePrincipalIsMemberOf cmdlet selects the groups in which a service principal is a member in Microsoft Entra ID.

Examples

Example 1: Get the group membership of a group for a service principal

Connect-Entra -Scopes 'Application.Read.All'
$group = New-Object Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck
$group.GroupIds = (Get-EntraGroup -Top 10).Id
$servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq 'Helpdesk Application'"
Select-EntraGroupIdsServicePrincipalIsMemberOf -ServicePrincipalId $servicePrincipal.Id -GroupIdsForMembershipCheck $group
aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb

This command gets the group membership of a group for a specified service principal. Use the command Get-EntraGroup to get group Id and Get-EntraServicePrincipal to get service principal Id.

  • -ServicePrincipalId parameter specifies the service principal Id.
  • -GroupIdsForMembershipCheck parameter specifies the array of group object IDs.

Parameters

-GroupIdsForMembershipCheck

Specifies an array of group object IDs.

Parameter properties

Type:GroupIdsForMembershipCheck
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-ServicePrincipalId

Specifies the ID of a service principal in Microsoft Entra ID.

Parameter properties

Type:System.String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:ObjectId

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.