PowerShell Genie

Inventory Entra groups

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Inventory Entra ID groups with Microsoft Graph PowerShell, selecting the group properties needed for a directory report.

The script

1PS> Get-MgGroup -All -Property DisplayName,SecurityEnabled,MailEnabled,GroupTypes | Select-Object DisplayName,SecurityEnabled,MailEnabled,GroupTypes

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 DisplayName SecurityEnabled MailEnabled GroupTypes
    2 ------------------ --------------- ----------- ----------
    3 IT Operations True False {}
    4 Microsoft 365 Demo False True {Unified}
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-MgGroup -All -Property DisplayName,SecurityEnabled,MailEnabled,GroupTypes | Select-Object DisplayName,SecurityEnabled,MailEnabled,GroupTypes
    1. Stage 1Get-MgGroup-All -Property
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Inventory Entra ID groups with Microsoft Graph PowerShell, selecting the group properties needed for a directory report. SecurityEnabled and MailEnabled together identify the classic group type, and GroupTypes is an array whose contents reveal whether the group is a Microsoft 365 group or uses dynamic membership.

      Adapting it

      Expand GroupTypes into readable text with a calculated property that joins the array, otherwise a CSV export writes the array's type name in place of its contents.

      Requirements

      Microsoft.Graph module and a Graph session with Group.Read.All.

      If the result is unexpected

      The Entra group inventory omits groups or membership details.

      A group-list query does not automatically expand all members, and pagination or permissions may constrain results.

      1. Confirm tenant and paging, then request membership separately for one known group.

      Validate the result

      The group list is complete for its scope and membership data is clearly identified as a separate query.

      Keep the check reliable

      Document which group types and membership depth the report covers.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideInventory Entra groups

      Inventory Entra ID groups with Microsoft Graph PowerShell, selecting the group properties needed for a directory report.