msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Get-MgGroupMember doesn't return service principals as group members

Open mykolaichuk opened this issue 1 year ago • 3 comments

Describe the bug

I was trying to list all members (users, nested groups, devices, service principals) of certain Entra ID groups, using Get-MgGroupMember cmdlet. I found that in a list of groups I was interested in I found only one user, but in fact there was a user and service principal.

I checked another group that has SPs as group members only and Get-MgGroupMember showed that it is empty.

Expected behavior

According to the cmdlet synopsis, Get-MgGroupMember should do following:

Get a list of the group's direct members. A group can have users, organizational contacts, devices, service principals and other groups as members.

But in fact it doesn't display SPs.

How to reproduce

  1. Create an Entra ID group with a service principal member.
  2. Execute Get-MgGroupMember -GroupId $GroupId.
  3. Observe missing SP id in the output.

SDK Version

2.20.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

- OS: Windows 11
- OS Build: 22H2 22621.3737
- Arch: x64
- PSVersion: 5.1.22621.3672

### Other information

_No response_

mykolaichuk avatar Jul 18 '24 13:07 mykolaichuk

@mykolaichuk A workaround for this bug is to specify the -ConsistencyLevel and -CountVariable parameters. The following command will output service principals too.

PS> Get-MgGroupMember -GroupId 'b0c07cae-5f21-49db-b4a3-c42f53b98a8d' -ConsistencyLevel eventual -CountVariable members

alexandair avatar Jul 26 '24 13:07 alexandair

Anyone? @timayabi2020 ?

mykolaichuk avatar Jan 13 '25 14:01 mykolaichuk

This is still an ongoing issue...

@alexandair thanks for the workaround

jinyeow avatar Apr 08 '25 11:04 jinyeow

Still an issue. Thanks for the workaround! @alexandair

B-Oudehinken avatar Jul 17 '25 15:07 B-Oudehinken

Still an issue

lily-aurelia avatar Aug 13 '25 11:08 lily-aurelia