Distribution group inventory
Documentation: Microsoft Learn
Get-DistributionGroup with -ResultSize Unlimited enumerates every distribution and mail-enabled security group, and the projection keeps just the display name and primary SMTP address.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
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-DistributionGroup -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,GroupType- Stage 1Get-DistributionGroup
-ResultSize - Stage 2Select-Object
Positional values or no named parameters
How it works
Get-DistributionGroup with -ResultSize Unlimited enumerates every distribution and mail-enabled security group, and the projection keeps just the display name and primary SMTP address.
Adapting it
Add GroupType and ManagedBy to the property list, because the owner field is what determines whether a group has anyone left to consult before it gets retired.
Requirements
ExchangeOnlineManagement module with a Connect-ExchangeOnline session.
If the result is unexpected
A distribution-group inventory is missing mail-enabled groups.
The selected command and recipient-type filter may not cover every group category.
- Inspect a known group's recipient type and select the query that matches that type.
Validate the result
The report includes its intended group category and documents excluded types.
Keep the check reliable
Avoid presenting one group-type inventory as a directory-wide group inventory.