PowerShell Genie

Mailbox inventory

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Get-EXOMailbox with -ResultSize Unlimited pages through all recipients rather than stopping at the default first thousand.

The script

1PS> Get-EXOMailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,RecipientTypeDetails,UserPrincipalName

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 PrimarySmtpAddress RecipientTypeDetails UserPrincipalName
    2 ----------- ------------------ -------------------- -----------------
    3 Sample object user@example.test UserMailbox user@example.test
    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-EXOMailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress,RecipientTypeDetails,UserPrincipalName
    1. Stage 1Get-EXOMailbox-ResultSize
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Get-EXOMailbox with -ResultSize Unlimited pages through all recipients rather than stopping at the default first thousand. The projection keeps display name and primary address with RecipientTypeDetails, which is the field distinguishing a shared mailbox from a regular one, plus the UPN for joining against directory data.

      Adapting it

      Pass -RecipientTypeDetails UserMailbox to the retrieval to exclude shared and resource mailboxes at the service, which is considerably faster than pulling everything and filtering afterward.

      Requirements

      ExchangeOnlineManagement module with an active Connect-ExchangeOnline session.

      If the result is unexpected

      The mailbox list excludes recipients visible elsewhere.

      Recipient types, result limits, tenant context and Exchange connection state affect mailbox queries.

      1. Confirm the Exchange organization and inspect the recipient type of a known missing object.

      Validate the result

      The report includes the intended mailbox types and states exclusions explicitly.

      Keep the check reliable

      Record tenant, recipient filters and result-limit settings with exports.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideMailbox inventory

      Get-EXOMailbox with -ResultSize Unlimited pages through all recipients rather than stopping at the default first thousand.