Jan 11

Exchange 2013 Database Status Report

I just knocked this out to give a quick display of the status of all Exchange databases across all mailbox servers in the org. you could convert the table to HTML and email it at the end, log to a csv, or just display it in the Powershell window. The script is fully generic so you don’t need to tell it database or server names. It will pull those from Exchange.

### Message Logs Search ###
Write-Host "Loading Exchange Management Powershell Modules"
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010, Microsoft.Exchange.Management.PowerShell.Setup , Microsoft.Exchange.Management.Powershell.Support

# Load all mailbox databases
$dbs = Get-MailboxDatabase

# Load all mailbox servers
$servers = (Get-ExchangeServer | WHERE ServerRole -Contains Mailbox | SORT Name).name

# Declare a variable to store the results
$allStats = @()

# Loop through each database
foreach($db in $dbs){
# Load the status of all copies of this database
$dbStats = Get-MailboxDatabaseCopyStatus $db.name | SELECT DatabaseName,MailboxServer,Status,ContentIndexState

# Create a PSObject to store the results
$dbProperty = New-Object PSObject

# Add the Database property and store the Database name
$dbProperty | Add-Member NoteProperty Database($db.Name)

# Loop through each mailbox server
foreach($server in $servers){
# Clear the $dbStat variable
$dbStat = $null

# Set the $dbStat Variable to the Database Copy Status on this server
$dbStat = $dbStats | WHERE MailboxServer -EQ $server

# $dbStat will be Null if this database does not have a copy on this server
if($dbStat -eq $null){ $dbStatus = $null }
# Get the DB Copy Status and Content Index State then combine into one string
$dbStatus = $dbStat.Status
$ciStatus = $dbStat.ContentIndexState
$dbStatus = “$dbStatus/$ciStatus”
# Add a property to the PSObject with the status of this database on this server
$dbProperty | Add-Member NoteProperty $server($dbStatus)
# Add the results for this database to $allStats
$allStats += $dbProperty

# Display the results
$allStats | ft -AutoSize

# Export the results to a file
#$allStats | Export-Csv “\\Path\to\csv\file.csv” -NoTypeInformation

Permanent link to this article: https://www.wperry.net/uncategorized/exchange-2013-database-status-report/

Leave a Reply

Your email address will not be published.