Select-EntraGroupIdsServicePrincipalIsMemberOf
Selects the groups in which a service principal is a member.
Syntax
Select-EntraGroupIdsServicePrincipalIsMemberOf
-ObjectId <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'
$groups = New-Object Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck
$groups.GroupIds = (Get-EntraGroup -Top 10).Id
$servicePrincipal = Get-EntraServicePrincipal -Filter "DisplayName eq '<service-principal-display-name>'"
Select-EntraGroupIdsServicePrincipalIsMemberOf -ObjectId $servicePrincipal.Id -GroupIdsForMembershipCheck $groups
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.
-ObjectId
parameter specifies the service principal Id.-GroupIdsForMembershipCheck
parameter specifies the array of 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 service principal in Microsoft Entra ID.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |