The script can be used in business rules, custom commands and scheduled tasks to check user mailbox size. It returns True if the mailbox size exceeds a certain limit. To use the script in your rule, command or task, add the If PowerShell script returns true condition.
Parameter:
- $limitGigabytes - Specifies the mailbox size limit (in gigabytes).
PowerShell
$limitGigabytes = 2 # TODO: modify me
# Get Exchange properties
$mailboxParams = $Context.TargetObject.GetMailParameters()
# Get mailbox size
$sizeInGBytes = $mailboxParams.UsageInfo.Size.GetGBytes()
$Context.ConditionIsMet = $sizeInGBytes -ge $limitGigabytes