Most Exchange organizations use mailbox quotas to help users manage the size of their mailbox and to keep storage utilization in check. Managing quotas can be a burden on Exchange administrators, the help desk, and users, but with a few tweaks things can be made easier.
Exchange Mailbox Quota Types
Mailbox quotas can be set at the database or mailbox level. Quotas set at the mailbox level will take precedence over database quotas. Additionally, quotas can be a hard limit, preventing sending and/or receiving e-mail, or just a warning threshold which triggers a warning message. It’s important to choose the right type of quotas to set – do you want users to be warned about their mailbox size, or do you want to prevent them from sending or receiving e-mail if they exceed their quota? The three mailbox quota types are:
- Issue Warning Quota –
-
this is not a hard limit, but a warning threshold. When it has been exceeded the user will get a warning message about their mailbox size, but will still be able to send and receive e-mail.
- Prohibit Send Quota
-
this is a hard limit, and once a mailbox size exceeds it the user will no longer be able to send e-mail, but will still be able to receive e-mail.
- Prohibit Send and Receive Quota –
-
this is also a hard limit, and once it is exceeded the user will no longer be able to send or receive e-mail messages. Incoming e-mail will be returned to the sender.
Customizing Quota Messages
To make things easier for users, and to reduce the number of calls to the helpdesk, the messages which Exchange sends when a user is exceeding a quota limit can be customized to include more useful or practical information than the standard message gives. Custom quota messages also support HTML, so you can include formatting or other HTML, such as link to a self-help knowledgebase article offering tips on reducing mailbox size. In previous versions of Exchange modifying the quota messages was difficult and usually required programming skills, or custom DLL files, but with Exchange 2007 it can all be done with the PowerShell command line.
While there are only three mailbox quota types, there are four quota message types as a warning quota can be set with or without a hard limit quota. Custom messages can be set for all four quota message types:
- WarningMailboxUnlimitedSize –
-
this message type is sent to mailboxes which have no size limit when the warning quota has been exceeded.
- WarningMailbox –
-
this message type is sent to mailboxes which have a size limit (such as a Prohibit Send or Prohibit Send and Receive quota) when the warning quota has been exceeded.
- ProhibitSendMailbox –
-
This message type is sent when the Prohibit Send storage quota is exceeded.
- ProhibitSendReceiveMailBox –
-
This message type is sent when the Prohibit Send and Receive storage quota is exceeded.
The New-SystemMessage cmdlet is used to set a custom quota message:
1 |
New-SystemMessage -QuotaMessageType WarningMailbox -Language EN -Text "My custom quota message." |
This command will set an HTML custom message which includes a hyperlink:
1 |
New-SystemMessage -QuotaMessageType WarningMailbox -Language EN -Text "<p>You are approaching the maximum size of your mailbox.</p><p>Please see this article for details on how to reduce your mailbox size: <a href=http://intranet.example.com/kb/mailboxsize.html> http://intranet.example.com/kb/mailboxsize.html</a></p>" |
Once a custom quota message has been set it can be viewed using the Get-SystemMessage cmdlet:
1 |
Get-SystemMessage -Identity EN\WarningMailbox | Format-List |
It can be modified using the Set-SystemMessage cmdlet:
1 |
Set-SystemMessage -Identity EN\WarningMailbox -Text "My modified custom quota message." |
And it can be removed using the Remove-SystemMessage cmdlet:
1 |
Remove-SystemMessage -Identity EN\WarningMailbox |
Quota messages are sent according to a schedule defined on each mailbox database. The default schedule is daily, between 1am and 1.15am. The schedule can be altered using the Set-MailboxDatabase cmdlet.
This command will set the database “Mailbox Database” on server “EXCHANEG01” to send quota notifications on Sundays and Wednesdays between 7am and 8am:
1 |
Set-MailboxDatabase -Identity "EXCHANGE01\Mailbox Database" -QuotaNotificationSchedule "Sun.7:00-Sun.8:00","Wed.7:00-Wed.8:00" |
You must be delegated the Exchange Organization Administrator role to use the *-SystemMessage cmdlets. You must be delegated the Exchange Server Administrator role and be a member of the local Administrators group for the target server to use the Set-MailboxDatabase cmdlet.
Retrieving Mailbox Sizes and Quotas
Mailbox sizes are retrieved using the Get-MailboxStatistics cmdlet.
1 |
Get-MailboxStatistics juser | fl TotalItemSize |
Mailbox Quotas are retrieved using the Get-Mailbox cmdlet.
1 |
Get-Mailbox juser | fl *Quota |
This simple script combines Get-MailboxStatistics with Get-Mailbox to show mailbox size and prohibit send quota in one command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# Get-MailboxQuota.ps1 # Script for showing mailbox size and quota # Exit the script if username is not found If ($args[0] -eq $null) { Write-Host "Error: No user specified" -ForegroundColor "Red" break } # Get the username from the command line argument $username = $args[0] # Get the mailbox, break if it's not found $mb = Get-Mailbox $username -ErrorAction Stop # Get the mailbox statistics $mbstats = Get-MailboxStatistics $username # If the mailbox is using the database quotas then read them, otherwise read them from the mailbox If ($mb.UseDatabaseQuotaDefaults -eq $true) { $quota = (Get-MailboxDatabase -Identity $mb.Database).ProhibitSendQuota.Value.ToMB() } else { $quota = $mb.ProhibitSendQuota.Value.ToMB() } # Get the mailbox size and convert it from bytes to megabytes $size = $mbstats.TotalItemSize.Value.ToMB() # Write the output Write-Host "Mailbox: " $mb.DisplayName Write-Host "Size (MB): " $size Write-Host "Quota (MB):" $quota Write-Host "Percent: " ($size/$quota*100) Write-Host |
You must be delegated the Exchange View-Only Administrator role to use the Get-Mailbox and Get-MailboxStatistics cmdlets.
Setting Mailbox Quotas
Mailbox quotas can be set in two places – directly on the mailbox or on the mailbox database. By default Exchange 2007 sets a quota of 2000MB on all new mailbox databases, and all mailboxes in the database inherit this value.
The Set-MailboxDatabase cmdlet is used to set default quotas on a mailbox database using the PowerShell command line.
This command will set the default warning quota on the database “Mailbox Database” on server EXCHANGE01 to 975MB, and the limit at which users will no longer be able to send mail to 1000MB:
1 |
Set-MailboxDatabase "EXCHANGE01\Mailbox Database" -IssueWarningQuota 975MB -ProhibitSendQuota 1000MB |
The Set-Mailbox cmdlet is used to set quotas on individual mailboxes.
This command will set the warning quota for user juser to 1475MB, and the limit at which the user will no longer be able to send mail to 1500MB. It will also configure the mailbox not to use the database default quotas:
1 |
Set-Mailbox juser -IssueWarningQuota 1475MB -ProhibitSendQuota 1500MB -UseDatabaseQuotaDefaults $false |
Quota increase requests will be fairly common for most organizations which use mailbox quotas. Quota increases are usually governed by an IT policy, and increases are usually in fixed amounts. This PowerShell script will automatically increment the quota size of a specified mailbox by a given amount. This script, or something like it, can be used to decrease the administrative overhead of mailbox quotas. The script reads the current quota from the database or from the mailbox, shows what the existing quota is and what the new quota will be, then prompts for confirmation before setting the new quotas. It then displays confirmation that the new values have been set. If the current quota is not a multiple of the increment specified it will be rounded up to the next increment, rather than having an increment added, which ensures that quotas are always a multiple of the desired increment value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# Increase-MailboxQuota.ps1 # Script for incrementing mailbox quotas # Amount to increase prohibit send quota by in megabytes $QuotaIncrement = 250 # Amount to subtract from prohibit send quota to set warning quota $WarningDifference = 25 # Get the username from the arguments $username = $args[0] # Prompt if no location was passed if (-not $username) { $username = Read-Host "Username" } # Get the mailbox $Mailbox = Get-Mailbox -Identity $username -ErrorAction Silentlycontinue # Error if the mailbox wasn't found If (-not $mailbox) { Write-Host "User not found" -Foregroundcolor:Red break } # Get the mailbox information and size $DisplayName = $Mailbox.DisplayName $Database = $Mailbox.Database $UsingDBQuotas = $Mailbox.UseDatabaseQuotaDefaults $MailboxSize = (Get-MailboxStatistics -Identity $Mailbox.Name).TotalItemSize.value.ToMB() # Get the current quota values if ($UsingDBQuotas -eq $True) { # Database quotas are being used so read them from the DB $Database = Get-MailboxDatabase -Identity $Database $ProhibitSendQuota = $Database.ProhibitSendQuota.value.ToMB() $IssueWarningQuota = $Database.IssueWarningQuota.value.ToMB() } else { # Mailbox quotas are being used so read them from the mailbox $ProhibitSendQuota = $Mailbox.ProhibitSendQuota.value.ToMB() $IssueWarningQuota = $Mailbox.IssueWarningQuota.value.ToMB() } # Calculate the new prohibit send quota If (($ProhibitSendQuota % $QuotaIncrement) -eq 0) { # Existing quota is a multiple of $QuotaIncrement so increase it by $QuotaIncrement $NewProhibitSendQuota = $ProhibitSendQuota + $QuotaIncrement } Else { # Existing quota is not a multiple of $QuotaIncrement so round it up to nearest multiple of $QuotaIncrement $NewProhibitSendQuota = $ProhibitSendQuota + ($QuotaIncrement - ($ProhibitSendQuota % $QuotaIncrement)) } # Calculate the new warning value $NewIssueWarningQuota = $NewProhibitSendQuota - $WarningDifference # Show what we're going to do Write-Host "" Write-Host "Full Name: ", $DisplayName Write-Host "Database: ", $Database Write-Host "Using Default Quota: ", $UsingDBQuotas Write-Host "" Write-Host "Mailbox Size (MB): ", $MailboxSize, "MB" Write-Host "" Write-Host "Current Quota: ", $ProhibitSendQuota, "MB" Write-Host "Current Warning: ", $IssueWarningQuota, "MB" Write-Host "" Write-Host "New Quota: ", $NewProhibitSendQuota, "MB" Write-Host "New Warning: ", $NewIssueWarningQuota, "MB" Write-Host "" $Continue = Read-Host "Continue [Y/N]?" # Ask if we want to continue Switch ($Continue) { "Y" {$Continue = $True} "y" {$Continue = $True} } # Stop here if not continuing If ($Continue -ne $True) { break } # Set the new values on the mailbox $NewProhibitSendQuota = [STRING]$NewProhibitSendQuota + "MB" $NewIssueWarningQuota = [STRING]$NewIssueWarningQuota + "MB" Set-Mailbox -Identity $Mailbox -UseDatabaseQuotaDefaults $False -ProhibitSendQuota $NewProhibitSendQuota -IssueWarningQuota $NewIssueWarningQuota # Update the mailbox quota information $Mailbox = Get-Mailbox $Mailbox $ProhibitSendQuota = $Mailbox.ProhibitSendQuota.value.ToMB() $IssueWarningQuota = $Mailbox.IssueWarningQuota.value.ToMB() # Write some output to confirm the new values Write-Host "" Write-Host "Updated Quota: ", $ProhibitSendQuota, "MB" Write-Host "Updated Warning: ", $IssueWarningQuota, "MB" Write-Host "" |
You must be delegated the Exchange Recipient Administrator role to use the Set-Mailbox cmdlet
Configuring the Mailbox Information Cache Refresh Interval
Exchange quota information is stored in Active Directory, and by default is cached by Exchange for up to two hours. This means that it could take up to two hours for a quota change to take effect. The recommended interval for Exchange to refresh quota information is 20 minutes, which can be set by adding three registry values.
Note – setting the cache refresh intervals too low can adversely affect the performance of Exchange. Incorrectly editing the registry can cause serious problems that may require you to reinstall your operating system. Problems resulting from editing the registry incorrectly may not be able to be resolved. Before editing the registry, back up any valuable data. You need to be a local administrator on the Exchange server in order to edit the registry.
- Start the registry editor on your Exchange 2007 Mailbox server
- Locate the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchangeIS\ParametersSystem key.
- Create the “Reread Logon Quotas Interval” value
- Right-click ParametersSystem, select New, and then select DWORD value.
- Name the new DWORD value “Reread Logon Quotas Interval”.
- Right-click Reread Logon Quotas Interval, and then click Modify.
- Enter a decimal value of 1200 seconds (20 minutes)
- Create the “Mailbox Cache Age Limit” value
- Right-click ParametersSystem, select New, and then select DWORD value.
- Name the new DWORD value “Mailbox Cache Age Limit”.
- Right-click Mailbox Cache Age Limit, and then click Modify.
- Enter a decimal value of 20 (20 minutes)
- Locate the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchange ADAccess key.
- Create the “CacheTTLUser” value
- Right-click MSExchange ADAccess, select New, and then select Key.
- Name the new key Instance0.
- Right-click Instance0, select New, and then select DWORD value.
- Name the new DWORD value “CacheTTLUser”.
- Right-click CacheTTLUser, and then click Modify.
- Enter a decimal value of 300 (5 minutes)
Alternately, copy this text file and paste it into a file called MailboxCache.reg, then import it into the registry of each of your Exchange 2007 Mailbox servers
1 2 3 4 5 6 7 8 9 |
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchangeIS\ParametersSystem] "Reread Logon Quotas Interval" =dword:000004b0 "Mailbox Cache Age Limit" =dword:00000014 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchange ADAccess\Instance0] "CacheTTLUser" =dword:0000012cc |
The Exchange Information Store service needs to be restarted for the change to become effective. More information about these changes can be found on the Microsoft TechNet web site.
Load comments