Every upgrade, every time, there seems to be one forgotten mailbox that wasn’t moved and we get the infamous pop-up like so:

So what to do? There are so many possible types of mailboxes that could be causing us issues:
- Arbitration
- AuditLog
- AuxAuditLog
- Archive
- Monitoring
- RemoveArchive
- Migration
How can discover be handled programmatically? Well, we can build a PowerShell script that can take a look at a particular server and let you know what mailboxes exist that are impeding its removal. The script below is a bit over done, but it provides a good visual on what mailboxes are on that server:
Code
# Script to move all system mailboxes and remove excess HealthMailboxes
CLS
Write-host '######################################' -ForegroundColor Green
Write-host '# ' -ForegroundColor Green -NoNewLine
Write-host 'System / Non-Primary Mailbox Check' -ForegroundColor White -NoNewLine
Write-host ' #' -ForegroundColor Green
Write-host '######################################' -ForegroundColor Green
Write-Host ' '
Write-Host ' '
# Pause for a sec #
start-Sleep 4
## Script Body ##
Write-host 'Which Exchange Server do you want to check' -ForegroundColor Yellow -NoNewLine
Write-host " for mailboxes? ('d' - default or enter name) " -ForegroundColor Yellow -NoNewLine
$Answer = Read-host
If ($Answer -eq 'd') {
# Server Name Check
$ExchangeServer = $Env:ComputerName
$AllServers = (Get-ExchangeServer).name
If ($AllServers -Contains $ExchangeServer){
$ExServer = $ExchangeServer
} Else {
Write-host "Error - this is not an Exchange Server!" -ForegroundColor Red
}
} Else {
# Server Name Check
$AllServers = (Get-ExchangeServer).name
If ($AllServers -Contains $Answer){
$ExServer = $Answer
} Else {
Write-host "Error - this is not an Exchange Server!" -ForegroundColor Red
}
}
Write-host " "
Write-host " "
Write-host "Checking the Exchange Server $ExServer for mailboxes now...." -ForegroundColor Yellow
Write-host " "
# Mailbox Check
$ArbitrationMailboxes = Get-Mailbox -Arbitration -Server $ExServer | Select-Object Name,ServerName
$ArchiveMailboxes = Get-Mailbox -Archive -Server $ExServer | Select-Object Name,ServerName
$AuditLogMailboxes = Get-Mailbox -AuditLog -Server $ExServer | Select-Object Name,ServerName
$AuxAuditLogMailboxes = Get-Mailbox -AuxAuditLog -Server $ExServer | Select-Object Name,ServerName
$MigrationMailboxes = Get-Mailbox -Migration -Server $ExServer | Select-Object Name,ServerName
$MonitoringMailboxes = Get-Mailbox -Monitoring -Server $ExServer | Select-Object Name,ServerName
$PublicFolderMailboxes = Get-Mailbox -PublicFolder -Server $ExServer | Select-Object Name,ServerName
# ARBITRATION MAILBOX CHECK:
# --------------------------
If ($Null -ne $ArbitrationMailboxes) {
Write-Host "Arbitration " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $ArbitrationMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,Arbitration"
}
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "Arbitration " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
# Archive MAILBOX CHECK:
# --------------------------
If ($Null -ne $ArchiveMailboxes) {
Write-Host ""
Write-Host "Archive " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $ArchiveMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,Archive"
}
Write-Host ""
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "Archive " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
# AuditLog MAILBOX CHECK:
# --------------------------
If ($Null -ne $AuditLogMailboxes) {
Write-Host ""
Write-Host "AuditLog " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $AuditLogMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,AuditLog"
}
Write-Host ""
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "AuditLog " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
# AuxAuditLog MAILBOX CHECK:
# --------------------------
If ($Null -ne $AuxAuditLogMailboxes) {
Write-Host ""
Write-Host "AuxAuditLog " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $AuxAuditLogMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,AuxAuditLog"
} Write-Host ""
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "AuxAuditLog " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
# Migration MAILBOX CHECK:
# --------------------------
If ($Null -ne $MigrationMailboxes) {
Write-Host ""
Write-Host "Migration " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $MigrationMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,Migration"
}
Write-Host ""
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "Migration " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
# Monitoring MAILBOX CHECK:
# --------------------------
If ($Null -ne $MonitoringMailboxes) {
Write-Host ""
Write-Host "Monitoring " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $MonitoringMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,Monitoring"
}
Write-Host ""
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "Monitoring " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
# PublicFolder MAILBOX CHECK:
# --------------------------
If ($Null -ne $PublicFolderMailboxes) {
Write-Host ""
Write-Host "PublicFolder " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found:" -ForegroundColor White
Write-host "------------------------------" -ForegroundColor White
Write-host "Name,Server,Type"
Foreach($Mailbox in $PublicFolderMailboxes) {
$Server = $Mailbox.ServerName
$Mbx = $Mailbox.Name
write-host "$Mbx,$Server,PublicFolder"
}
Write-Host ""
} Else {
Write-host "No " -ForegroundColor White -NoNewLine
Write-Host "PublicFolder " -ForegroundColor Green -NoNewLine
Write-host "mailboxes found" -ForegroundColor White
}
Sample Run Through
Here is a sample run through for discovering these mailboxes on either Exchange 2016 or Exchange 2019.


Conclusion</strong
Hope you find this script useful in your migrations / maintenance of Exchange Server 2016/2019.
