How to Use Set-MailboxDatabase Cmdlet?
Summary: The Set-MailboxDatabase cmdlet is used to configure different properties for an Exchange mailbox database. In this article, you’ll learn how to use the Set-MailboxDatabase cmdlet with different parameters. In addition, you’ll get know about an Exchange repair tool that can help you recover database in case of any issues.
In Exchange Server, the Exchange Management Shell (EMS) is used for scripting and to automate the Exchange Server execution with PowerShell commands. One of the important commands is the Set-MailboxDatabase command, which is used for various operations revolving around the Exchange Server database – be it a local single-server database or a database in Database Availability Group (DAG) in a high availability setup. This command is available in on-premises Exchange Server 2013 and later versions till Exchange Server 2019.
The command has a variety of properties that can be set on a database. In this article, we will discuss this command and the common parameters used with this command.
For complete command syntax, you can refer to this Microsoft document.
Usage of the Command
If you need to setup more configurations on the same database, you can either do a line for each one or simply add more parameters to the command line.
Set-MailboxDatabase -Identity <mailboxdatabase> -<parameter> <parameter setting>
Exclude from Auto Provisioning
One of the syntaxes that is used with the command is -IsExcludedFromProvisioning. This is helpful especially with helpdesk where you would immediately know if the mailbox is for users. Sometimes, administrators set a mailbox database to be on high-available and fast access drives with very large storage quota for the management users or VIP users. In this case, you don’t want any other mailbox configured on this mailbox database which would be provisioned using the automatic provisioning. For this reason, you would need to setup the exclusion using the command as given below.
Set-MailboxDatabase -Identity "<mailboxdatabase>" -IsExcludedFromProvisioning $true
If you need to disable this option, simply run the same command with the $false value.
Setting Database Limits
You need to classify the users depending on their limit. Instead of setting a limit per user, you can centralize all the users with the same limit on a single or multiple databases and set the limit there. The advantage of this is that you don’t have to worry to set the limit for new users as it will be set automatically when provisioned on the said database.
This can be done by using the quota parameters as given below.
Set-MailboxDatabase -Identity "<mailboxdatabase>" -IssueWarningQuota <gb> -ProhibitSendQuota <gb> -ProhibitSendReceiveQuota <gb>
The above command (see screenshot) will set the database to issue a warning at 2 GB, prohibit the users from sending emails at 3 GB, and prohibit sending and receiving emails at 4 GB.
Configuring Retention/Limit for Deleted Items and Recoverable Items
To take care of the storage in your Exchange Server, you can set the limit on the mailbox storage and the retention on deleted items and recoverable items. For this, you can use the Set-MailboxDatabase cmdlet.
To set the retention on the deleted items, you can use the below command.
Set-MailboxDatabase -Identity <mailbox database> -DeletedItemRetention <number of days> -RetainDeletedItemsUntilBackup $true
As you can see from the screenshot above, the retention of the deleted items is set for 10 days on the database – DB01. Apart from that, the deleted items are also set to be removed after a full backup is taken. If you wish to leave the items in the folder until the retention period is over, simply change the RetainDeletedItemsUntilBackup to $false.
If you like to set a limit on the size of recoverable items on the mailbox database, you can use the RecoverableItemsWarningQuota and RecoverableItemsQuota parameters (see the below command).
Set-MailboxDatabase -Identity <mailbox database> -RecoverableItemsWarningQuota <GB Size> -RecoverableItemsQuota <GB Size>
Confirming the Changes
To confirm if the changes are incorporated on the said database, you can use the Get-MailboxDatabase command in the Exchange Management Shell.
Get-MailboxDatabase -Identity <mailbox database> | FL
All the parameters available for a mailbox database will be shown in the list.
To Conclude
You can use different parameters with the Set-MailboxDatabase command to set a variety of properties on a database. If some commands are incorrectly set, it may stop the mailbox database or create issues with the Exchange Server.
In such a case, you can take the help of an application, such as Stellar Repair for Exchange, to recover the data and shift it to a new live Exchange Server database. With this application, you can open multiple mailbox database files from any version of the Exchange Server. You can granularly export to PST and other file formats. You can also export mailboxes and public folders directly to a live Exchange Server database of any version or an Office 365 tenant.