The script is designed to check an Exchange Server for different types of system or non-primary mailboxes and display their details on the console. It also exports the results to a CSV file named “DisabledList.csv” in the  directory. Let’s break down the script step by step:

  1. The script starts by clearing the console using `CLS` and displaying a header to indicate the purpose of the script.
  2. It prompts the user to enter the name of the Exchange Server they want to check for mailboxes. The user can enter “d” for the default Exchange Server (local machine) or provide a specific server name.
  3. The script then checks if the provided server name exists among the Exchange Servers. If it finds a match, it assigns the provided server name or the default server name to the variable . If the server name does not match any Exchange Servers, an error message is displayed.
  4. After confirming the Exchange Server to check, the script proceeds to retrieve different types of system or non-primary mailboxes on that server using various `Get-Mailbox` commands with specific filters. The mailboxes are categorized into the following types.
    • Arbitration Mailboxes
    • Archive Mailboxes
    • AuditLog Mailboxes
    • AuxAuditLog Mailboxes
    • Migration Mailboxes
    • Monitoring Mailboxes
    • PublicFolder Mailboxes
  5. The script then iterates through each type of mailbox found and displays relevant information, including mailbox name, server name, and mailbox type.
  6. If no mailboxes of a particular type are found, a message indicating that no mailboxes of that type were found is displayed.
  7. After displaying all the mailbox information, the script exports the information to a CSV file named in the directory. However, there is a typo in this export command. The part “Object TotalItemSize –Descending” does not belong here and will likely cause an error. To fix this, the script should include the line `#` at the beginning of that line to comment it out or remove it altogether.

In summary, the script is a diagnostic tool that helps check and list different types of system or non-primary mailboxes on a specific Exchange Server and exports the results to a CSV file for further analysis.

Get the Script

Copy the script below or download the txt file.

# 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
}