Setting Max Concurrent Mailbox Moves on all CAS Servers

Have been working on a migration of a whole load of mailboxes. One of the first things I came across is the pre-defined limit on the number of concurrent mailbox moves that can be completed on a CAS server in an Exchange environment.

I knew that our environment could handle a few more moves than the limit of 2, particularly out of hours. I wanted to ensure that if anyone started any moves within business hours though that a limit was still applied.

So, I went and wrote this little script below. It goes through and updates all of the CAS servers in your Exchange environment and sets the value of the concurrent moves to whatever you specify. I then scheduled this to run each day at the end of the day to allow more scheduled moves overnight, and ran it again in the morning with the original limit of 2 moves just before we opened.

It uses Invoked Sessiosn too, so as long as remoting has been enabled on your CAS servers, then you don’t need Exchange installed on the box that you are going to run from.

# ----------------------------------------------------------------------------------------------------------
# PURPOSE:    Set the Max Concurrent Mailbox Moves on all CAS Servers
#
# VERSION     DATE         USER                DETAILS
# 1           24/06/2014   Craig Tolley        First version
#
#
# ----------------------------------------------------------------------------------------------------------
#Script Block to Run on Each Host
$ScriptBlock = {
    
    #Parameters
    $MaxMovesValue = 50
    #Start of Script
    Write-Output $("-"*50)
    Write-Output "Connected to: $(hostname)"
    #Get the Exchange Install Path, check it has been returned. Exit if not found.     
    [string]$ExInstallPath = $env:exchangeinstallpath 
    If ($ExInstallPath.Length -eq 0)
        {
        Write-Error "CAS Server $hostname did not return the Install Path."
        Exit
        }
    Else
        {
        Write-Output "Exchange is installed at: $ExInstallPath"
        }
        #Look up the location of the configuration file and check that it exists
    $ConfigFileName = $ExInstallPath + "bin\MSExchangeMailboxReplication.exe.config"
    If ((Test-Path $ConfigFileName) -eq $false)
        {
        Write-Error "Cannot find the MRS configuration file"
        Exit
        }
    #Create a backup of the configuration file. 
    Write-Output "Config Backup: $ConfigFileName.$(Get-Date -Format yyyyMMdd_HHmm).backup"
    Copy-Item $ConfigFileName -Destination ($ConfigFileName + "." + (Get-Date -Format yyyyMMdd_HHmm) + ".backup")
    #Configure the file with the specified values and save the changes. 
    Write-Output "Configuring XML File"
    [System.Xml.XmlDocument]$config = Get-Content ($ConfigFileName)
    $config.configuration.MRSConfiguration.MaxActiveMovesPerSourceMDB = [string]$MaxMovesValue
    $config.configuration.MRSConfiguration.MaxActiveMovesPerTargetMDB = [string]$MaxMovesValue
    $config.configuration.MRSConfiguration.MaxActiveMovesPerSourceServer = [string]$MaxMovesValue
    $config.configuration.MRSConfiguration.MaxActiveMovesPerTargetServer = [string]$MaxMovesValue
    $config.Save($ConfigFileName)
    
    #Restart the MRS to activate the changes. 
    Write-Output "Restarting Mailbox Replication Service"
    Get-Service MSExchangeMailboxReplication | Restart-Service -WhatIf
    
    Write-Output "Configuration Complete!"
    Write-Output $("-"*50)
    Write-Output ""
}
#Get all of the CAS Servers
$CAS = Get-ClientAccessServer
#Loop through all changing the setting. 
foreach($srv in $CAS)
    {
     Write-Output "Configuring CAS Server: $srv"
     Invoke-Command -ComputerName $srv -ScriptBlock $ScriptBlock
    }

Be the first to like.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.