Skip to content

Set-ExchangeMailboxQuotaConfig

Exchange: Configures storage quotas for a mailbox

#Requires -Version 5.1

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true)]
    [string]$Identity,

    [switch]$UseDatabaseDefaults,

    [string]$IssueWarningQuota,
    [string]$ProhibitSendQuota,
    [string]$ProhibitSendReceiveQuota,
    [string]$ArchiveQuota,
    [string]$ArchiveWarningQuota,
    [string]$RecoverableItemsQuota,
    [string]$RecoverableItemsWarningQuota
)

Process {
    try {
        $params = @{
            'Identity'                 = $Identity
            'UseDatabaseQuotaDefaults' = $UseDatabaseDefaults.IsPresent
            'Confirm'                  = $false
            'ErrorAction'              = 'Stop'
        }

        if (-not $UseDatabaseDefaults) {
            if ($IssueWarningQuota) { $params.Add('IssueWarningQuota', $IssueWarningQuota) }
            if ($ProhibitSendQuota) { $params.Add('ProhibitSendQuota', $ProhibitSendQuota) }
            if ($ProhibitSendReceiveQuota) { $params.Add('ProhibitSendReceiveQuota', $ProhibitSendReceiveQuota) }
            if ($ArchiveQuota) { $params.Add('ArchiveQuota', $ArchiveQuota) }
            if ($ArchiveWarningQuota) { $params.Add('ArchiveWarningQuota', $ArchiveWarningQuota) }
            if ($RecoverableItemsQuota) { $params.Add('RecoverableItemsQuota', $RecoverableItemsQuota) }
            if ($RecoverableItemsWarningQuota) { $params.Add('RecoverableItemsWarningQuota', $RecoverableItemsWarningQuota) }
        }

        Set-Mailbox @params

        $mailbox = Get-Mailbox -Identity $Identity -ErrorAction Stop
        $result = [PSCustomObject]@{
            Identity                 = $Identity
            UseDatabaseQuotaDefaults = $mailbox.UseDatabaseQuotaDefaults
            IssueWarningQuota        = $mailbox.IssueWarningQuota
            ProhibitSendQuota        = $mailbox.ProhibitSendQuota
            ProhibitSendReceiveQuota = $mailbox.ProhibitSendReceiveQuota
            Action                   = "QuotaConfigUpdated"
            Status                   = "Success"
            Timestamp                = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the Identity of the mailbox.

Off

If set, the mailbox uses the quota defaults defined on the database level.

Specifies the threshold at which a warning is issued to the user.

Specifies the threshold at which the user can no longer send messages.

Specifies the threshold at which the user can no longer send or receive messages.

Specifies the maximum size for the archive mailbox.

Specifies the warning threshold for the archive mailbox.

An interactive directory of PowerShell scripts.