powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[FEATURE] Get-PnPAzureADGroupMember should fetch nested group members

Open bckrma opened this issue 5 years ago • 4 comments

Reporting an Issue or Missing Feature

Get-PnPAzureADGroupMember throws an error when a a specified group has group objects as member

Expected behavior

Get-PnPAzureADGroupMember should return all member objects of the specified group, whether these are user or group objects. (Support for transitive membership would be nice)

Actual behavior

As soon as the group contains a group member object, the cmdlet fails with: Get-PnPAzureADGroupMember : Unable to cast object of type 'Microsoft.Graph.Group' to type 'Microsoft.Graph.User'. This behavior was tested with Azure AD security groups (cloud only) and mail enabled security groups (AAD synced).

Steps to reproduce behavior

Create a security group, add a group as member and try to list the group members with Get-PnPAzureADGroupMember -Identity $GroupID

What is the version of the Cmdlet module you are running?

Version: 1.7.63

Which operating system/environment are you running PnP PowerShell on?

  • [x] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

bckrma avatar Oct 04 '21 13:10 bckrma

Looking into it

KoenZomers avatar Oct 10 '21 19:10 KoenZomers

Tricky one. I can reproduce the issue, but it's difficult to fix it in a backwards compatible way. Let me see what I can do here.

KoenZomers avatar Oct 10 '21 20:10 KoenZomers

Submitted two PRs to deal with this: https://github.com/pnp/powershell/pull/1237 https://github.com/pnp/pnpframework/pull/490

Both need to be merged first. Then the next day you can get the latest prerelease to try if it works well for you. Assuming it does, closing this issue. If it does not work for you, report back and we will reopen.

Please open a separate request for the enhancement go recursively get the subgroup members or just loop through it yourself.

KoenZomers avatar Oct 11 '21 00:10 KoenZomers

Great, thank you very much!

bckrma avatar Oct 11 '21 08:10 bckrma