Skip to content
Menu

Mailbox Nearly Full - Size and Quota Report

One row per mailbox with size, quota, percent used, item count, Recoverable Items and archive size, fullest first. MinPercentUsed lists only the nearly full ones.

Mailbox nearly full - size and quota report is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Mailbox nearly full - size and quota report. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, 11, Server 2016+, with the app certificate; runs as SYSTEM or a user
NeedsPowerShell 5.1; Graph: Organization.Read.All; ExchangeOnlineManagement 3.1+, Exchange.ManageAsApp, read role
Read-onlyReads, changes nothing

What It Does

The script is read-only. It connects to Exchange Online as your app, lists the mailboxes (the user and shared mailboxes by default, or the one in TargetMailbox) and reads each mailbox's statistics. When a mailbox has an active archive and IncludeArchive is true, it reads the archive's size as well.

Each row gives the size and quota in GB, the percent of quota used, the item count, the Recoverable Items size with its percent of its quota, and archive size when read. It uses the send quota, falling back to the send and receive quota if necessary. A mailbox with no readable quota shows a blank quota.

Rows with a readable percentage are sorted fullest first and filtered by MinPercentUsed. At the default of 0, mailboxes with no readable percentage are listed at the end too. A positive threshold leaves those out. The report does not list the largest folders.

It makes two or three Exchange calls per mailbox, so a large tenant takes a while. If a mailbox read fails, the script warns, counts the failure in the answer, and moves on. If the ExchangeOnlineManagement module is not installed, the run is skipped.

Before You Run It

  • Register an app for this client with a certificate, and keep the certificate with its private key on the computer that runs the script.
  • Give the app the Microsoft Graph application permission Organization.Read.All and the Exchange.ManageAsApp permission.
  • Assign the app an Exchange role that can read mailbox statistics, for example Global Reader.
  • Install the ExchangeOnlineManagement module (version 3.1 or later) on the computer.
  • Start with MinPercentUsed=80 or 90 on a large tenant.
  • Set IncludeArchive=false for a faster run when you do not need archive sizes.

Type and Risk

  • Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: 1 to 30 minutes depending on the number of mailboxes.
  • Example answer: "120 mailbox(es) checked, 4 listed; fullest: [user sign-in] 98.4% (98.4 of 100 GB)"
  • Tested before listing with Windows PowerShell 5.1, run as SYSTEM, against its own test cases and a Microsoft 365 Business Premium test tenant.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • TenantId: The client's tenant ID (a GUID) or domain such as contoso.onmicrosoft.com. Required.
  • ClientId: The app registration's Application (client) ID, a GUID. Required.
  • CertificateThumbprint: Thumbprint of the app's certificate, with its private key in LocalMachine\My or CurrentUser\My on this computer. Preferred. Leave empty to use the ClientSecret environment variable.
  • TargetMailbox: One mailbox (its address or UPN). Default empty: every mailbox of the chosen MailboxType.
  • MailboxType: All (default: user and shared mailboxes), User or Shared. Ignored when TargetMailbox is set.
  • MinPercentUsed: List only mailboxes at or above this percent of quota, 0 to 100. Default 0 (all).
  • IncludeArchive: true (default) to read the archive size of mailboxes that have an active archive.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

get-mailbox-sizes.ps1 · 1058 lines · 59.2 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.