[FEATURE] Get-PnPAzureADGroupMember should fetch nested group members
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
Looking into it
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.
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.
Great, thank you very much!