msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Get-MgGroupMember doesn't return service principals as group members
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
- Create an Entra ID group with a service principal member.
- Execute Get-MgGroupMember -GroupId $GroupId.
- 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
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
Anyone? @timayabi2020 ?
This is still an ongoing issue...
@alexandair thanks for the workaround
Still an issue. Thanks for the workaround! @alexandair
Still an issue