Script repository

Check if mailbox size exceeds limit

Updated on: Jan 18, 2026, Views: 3120

Exchange

The script returns checks if mailbox size exceeds a certain size limit. To execute the script, use the If PowerShell script returns true condition in a business rule, custom command or scheduled task configured for the required object type. The script returns $true if the specified limit is exceeded.

In the script, the $limitGigabytes variable specifies the mailbox size limit (in gigabytes).

$limitGigabytes = 2 # TODO: modify me

# Get mailbox size.
$mailboxParams = $Context.TargetObject.GetMailParameters()
$sizeInGBytes = $mailboxParams.UsageInfo.Size.GetGBytes()

$Context.ConditionIsMet = $sizeInGBytes -ge $limitGigabytes

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.