In Exchange Server, the Set-MailboxServer PowerShell command is used to modify the mailbox configuration and the attributes of the mailbox servers, when having a Database Availability Group (DAG) in a clustered environment. In simple terms, this command lets you change the parameters and configuration of the databases in the high availability setup. In this article, we will see how to use this command, with various options.
How to Use Set-MailboxServer Command?
Before using this PowerShell cmdlet, you need to assign the right roles and permissions to the user. To get the roles needed to execute the command, open the Exchange Management Shell (EMS) window and run the following command:
You can see (in the above image) that the Role Type for the user’s permission needs to be set as ExchangeServers.
Next, you need to run the below command to get the exact permissions for the operation.
$Permissions = Get-ManagementRole -Cmdlet Set-MailboxServer
$Permissions | foreach {Get-ManagementRoleAssignment -Role $_.Name -Delegating $false | Format-Table -Auto Role,RoleAssigneeType,RoleAssigneeName}
As you can see (in the above image), the following permissions are required:
- Organization Management
- Server Management
You can set these permissions using the Exchange Admin Center (EAC). Follow the below steps:
- Open the EAC, click on Permissions, and then click on Admin Roles.
- Click on the Add button.
- Enter the desired name in the Name field.
- Click on the Add button in the Roles section and add Exchange Servers.
- Click on the Add button in the Members section and add the user which you will be using to execute the command.
After assigning the permissions, you can use this command using its different parameters.
Using the Command with Different Parameters
There are several parameters that you can use with the Set-MailboxServer command. However, we will go through some of the major ones. To see the full list of parameters you can set, run the below command.
Auto Database Mount Dial Parameter
The AutoDatabaseMountDial parameter specifies the mount behavior of databases after failover of the mailbox server. There are different values that you can use.
- BestAvailability: This will automatically and immediately mount the database in case of failover, when the copy queue length is less than or equal to 12.
- GoodAvailability: The database will mount immediately after failover if the copy queue length is less than or equal to 6.
LossLess: This will not mount the database automatically until all the logs, created by the active copy, are coped over to the passive server. This setting will also have the Active Manager best copy selection algorithm to sort the potential candidates to host the database based on their activation preference.
Database Copy Auto Activation Policy Parameter
This parameter specifies the type of activation of mailbox databases on the specified server. There are three values to this parameter.
- Blocked: This will not allow databases to automatically activate in case of failover, even if the server is the only available server.
- IntrasiteOnly: This will only allow the database copies to activate, only if the mailbox servers are in the same Active Directory site, preventing cross-site failover and activation.
- Unrestricted: There are no restrictions on the activation of the database. If other parameters are not set, this is the default value for the parameter.
Database Copy Activation Disabled and Move Now Parameter
This parameter specifies whether to prevent databases from being mounted on the mailbox server, in case you have a low performance server for just storing the database copies. The databases will not be mounted on the specified server if there are other servers which have healthy copies.
What to do if something went wrong?
There are many things that could go wrong when setting up the database copies and behavior manually via PowerShell, leading to various issues with replication or database integrity. So, you must have a contingency plan in case things go wrong. You can restore from backup but you would lose all the data from when the backup was taken to when the issue got critical. You can use the exchange server data recovery applications to restore the server after a rebuild, but the biggest challenge is to recover the data.
In such cases, where the database is corrupted, you can use specialized applications, such as Stellar Repair for Exchange. Recommended by many MVPs, this application can easily open multiple EDB files of any size and from any Exchange Server version. After a quick or deep scan of the database, it allows you to select the items and granularly export them to PST and other file formats. You can also export directly to a live Exchange Server or Office 365. It can process user mailboxes, shared mailboxes, user archives, disabled mailboxes, and public folders.