Exchange 2010 PowerShell Script to alert when Replay Queue Length gets above a Threshold

By |2017-12-07T09:45:43+00:00March 5th, 2012|Exchange, PowerShell|0 Comments

Just a quick PowerShell script we’ve wrote that will basically alert you when a Replay Queue Length goes above a configured threshold (In the below Scripts Case it’s a 1000 but you can alter to what you want)

It’s best to configure the below PowerShell to run in task scheduler on your server on an hourly occurrence . Please note an email will only be triggered when the Queue length goes above the value you’ve specified.

Please Edit the Below highlighted in red to suit your needs and then save the script to a PS1 and your all ready to run it Smile


Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Function sendEmail ([String] $body)
    $MailMessage = New-Object System.Net.Mail.MailMessage
    $MailMessage.From =
    $MailMessage.Subject = "Replay Queue Length Above 1000"
    $MailMessage.Body = $body
    $MailMessage.Priority = "High"

    $SMTPClient = New-Object System.Net.Mail.SMTPClient
    $SMTPClient.Host = "ExchangeServerName"

Get-MailboxServer | Get-MailboxDatabaseCopyStatus | ForEach {
    If ($_.ReplayQueueLength -gt "1000")
$body += "ServerName"
$body += "`r`n "
$body += $_.MailboxServer
$body += "`r`n "
$body += "Database"
$body += "`r`n "
$body += $_.DatabaseName
$body += "`r`n "
$body += "Replay Queue Length"
$body += "`r`n "
$body += $_.ReplayQueueLength
$body += "`r`n "
$body += "`r`n "
$body += "`r`n "
$body += "`r`n "
if ($Body -ne $null)
sendemail $Body}"


The Outpoint to email  will be like below





Replay Queue Length


Leave A Comment

like what you see? 

Sign-up to our newsletter and never miss out on the latest blogs, events and tech news from the world of risual
Give it a try, you can unsubscribe anytime.