Get-MgGroupMemberOfAsGroup Cmdlet

i) What is Get-MgGroupMemberOfAsGroup?

Get-MgGroupMemberOfAsGroup is a Microsoft Graph PowerShell cmdlet used to retrieve groups that a specific group is a member of.

In simple terms, it helps you identify nested group memberships where one group is part of another group.

🚀 Community Edition Released!

Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.

ii) Why Use MgGroupMemberOfAsGroup?

  • Identify nested group relationships
  • Audit group-to-group access structure
  • Troubleshoot permission inheritance issues
  • Understand hierarchical group design in large environments

iii) Prerequisites

  • Install Microsoft Graph PowerShell module:
  • Install-Module Microsoft.Graph -Scope CurrentUser

  • Connect to Microsoft Graph:
  • Connect-MgGraph -Scopes "Group.Read.All"

iv) Required API Permissions

Permission Type Permissions
Delegated Group.Read.All
Application Group.Read.All

Ensure admin consent is granted for application permissions.


v) How to use MgGroupMemberOfAsGroup?

Syntax

Get-MgGroupMemberOfAsGroup [-GroupId <String>]
  • Security: Misconfigured permissions can expose sensitive data. Always follow least-privilege principles.
  • Compliance: Ensure apps meet organizational and regulatory standards (GDPR, HIPAA).
  • Maintenance: Tokens, secrets, and certificates must be rotated regularly.
  • User Experience: Poorly designed redirect URIs or login flows can frustrate users.

vi) Usage Examples

  1. Entering GroupID When Prompted by PS Console
  2. Get-MgGroupMemberOfAsGroup
  3. Passing GroupID Parameter Directly
  4. Get-MgGroupMemberOfAsGroup -GroupId efba43ca-ff99-4f70-b2c5-a97e9dbb75d2

    Retrieves all groups that the specified group is a member of (nested group memberships).

  5. Selecting Only Specific Group Member Properties
  6. Get-MgGroupMemberOfAsGroup -GroupId efba43ca-ff99-4f70-b2c5-a97e9dbb75d2 | Select DisplayName,Id
  7. Exporting Group Membership Details to CSV
  8. Get-MgGroupMemberOfAsGroup | Export-CSV "D:/groups_group_is_direct_member_of.csv"

Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Created and Maintained by LEARNIT WELL SOLUTIONS. All Rights Reserved.