Skip to main content

Detect and fix mailbox migration issues with Retention settings

Troubleshoot the Recoverable Items folder filling up due to Holds on your destination mailboxes with Copy mailboxes and Copy from Gmail.

Updated over a week ago

When you copy mailboxes to Microsoft 365, specific retention or hold settings can cause the Recoverable Items folder to fill up at the destination.

The most common cause is Retention settings, which are often enabled by default on new Exchange Online mailboxes.

ShareGate Migrate detects this potential problem and lists the affected mailboxes in a report that you can find on the Copy Summary screen, which is displayed before you launch your mailbox migration.

How to identify problematic Retention settings and turn them off

You can identify and disable problematic Retention settings on mailboxes before launching your mailbox migration, and re-enable them afterward using the PowerShell scripts in this article.

When you set up a migration with Copy mailboxes or Copy from Gmail, you will get a warning notification in the Copy summary screen if any of your mailboxes have retention settings on them.

When you see the warning message, click Export list of Single Item Recovery values to save the list to your drive. Then, update the script below with the path to your exported CSV file and run it for your destination environment.

Once the script finishes running, wait at least 4 hours for the settings to take effect in Exchange Online before proceeding with your migration.

Disable Retention settings

$CsvPath = Read-Host "Replace this message with the absolute path of the report you saved on your drive between these quotation marks"

$CsvPath = $CsvPath.Trim('"')

if (-not $CsvPath) {
Write-Error "No path provided. Exiting."
return
}

if (-not (Test-Path -LiteralPath $CsvPath)) {
Write-Error "File not found at '$CsvPath'. Exiting."
return
}

$ErrorActionPreference = 'Stop'

$ModuleName = "ExchangeOnlineManagement"
$RequiredVersion = "3.9.0"

$module = Get-Module -ListAvailable -Name $ModuleName | Where-Object {
$_.Version -eq [Version]$RequiredVersion
}

if (-not $module) {
Install-Module -Name $ModuleName -RequiredVersion $RequiredVersion `
-Scope CurrentUser -Force -AllowClobber
}

Import-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force

Connect-ExchangeOnline -ShowBanner:$false

try {
$rows = Import-Csv -LiteralPath $CsvPath

foreach ($r in $rows) {
$email = $r.EmailAddress

if ($r.SingleItemRecoveryEnabled -ieq 'true') {
Set-Mailbox -Identity $email -SingleItemRecoveryEnabled $false
Write-Host "Disabled SingleItemRecovery: $email"
}

}
}
finally {
Disconnect-ExchangeOnline -Confirm:$false
}

Restore Retention settings

You can update the script below with the path to your exported CSV file and run it to enable the holds back on your destination.

$CsvPath = Read-Host "Replace this message with the absolute path of the report you saved on your drive between these quotation marks"

$CsvPath = $CsvPath.Trim('"')

if (-not $CsvPath) {
Write-Error "No path provided. Exiting."
return
}

if (-not (Test-Path -LiteralPath $CsvPath)) {
Write-Error "File not found at '$CsvPath'. Exiting."
return
}

$ErrorActionPreference = 'Stop'

$ModuleName = "ExchangeOnlineManagement"
$RequiredVersion = "3.9.0"

$module = Get-Module -ListAvailable -Name $ModuleName | Where-Object {
$_.Version -eq [Version]$RequiredVersion
}

if (-not $module) {
Install-Module -Name $ModuleName -RequiredVersion $RequiredVersion `
-Scope CurrentUser -Force -AllowClobber
}

Import-Module -Name $ModuleName -RequiredVersion $RequiredVersion -Force

Connect-ExchangeOnline -ShowBanner:$false

try {
$rows = Import-Csv -LiteralPath $CsvPath

foreach ($r in $rows) {
$email = $r.EmailAddress

if ($r.SingleItemRecoveryEnabled -ieq 'true') {
Set-Mailbox -Identity $email -SingleItemRecoveryEnabled $true
Write-Host "Enabled SingleItemRecovery: $email"
}
}
}
finally {
Disconnect-ExchangeOnline -Confirm:$false
}
Did this answer your question?