Zoho Banner September 2011

Archive for February, 2012

The other day I was doing some troubleshooting on a DAG member in a remote site.  I needed to get a picture of the copy and replay queues for the server over a period of time. To do this I wrote a small script to poll the queues at 60 second intervals over a 24 hour period.  The output is in CSV format to allow the results to examined/graphed using Excel.  I thought it might be useful to others.

#########################################################
#
# Name: Get-QueueLength.ps1
# Author: Tony Murray
# Version: 1.0
# Date: 25/01/2012
# Comment: PowerShell script to output DAG database
# queue lengths to file
#
#########################################################

$outfile = "c:\QueueLength.csv"

$server = "MyExchangeServer"

$head = "Date,Time,Database,CopyQLength,ReplayQLength"

if (Test-Path $OutFile) {Remove-Item $outfile}

Add-Content -Value $head -Path $outfile

$i = 0
do {
    $dat = Get-Date -Format d
    $tim = get-date -Format HH:mm
    $stats = Get-MailboxDatabaseCopyStatus -Server $server
    foreach ($stat in $stats) {
        $dba = $stat.databasename
        $clen = $stat.CopyQueueLength
        $rlen = $stat.ReplayQueueLength
        $line = "$dat,$tim,$dba,$clen,$rlen"
        Write-Host $line
        Write-Host $i
        Add-Content -Value $line -Path $Outfile
    } # End foreach
    $i = $i + 1
    Start-Sleep -Seconds 60
    } # End of Do
While ($i -le 1439)