Get-HTQueueStats.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Get-HTQueueStats {
    [CmdletBinding()]
    param (
        # Pattern to match with the queue name, default evt queues
        [Parameter(Position=1)]
        [string]$QueueNamePattern="*evt_*",

        # Refresh Rate
        [Parameter(Position=2)]
        [int]$RefreshPerSecond = 1
    )

    process {
        While($true)
        {
        Clear-Host
        $queues = Get-MsmqQueue | Where-Object { $_.QueueName -like  $QueueNamePattern } 
        $queues = $queues | Sort-Object QueueName  | Select-Object QueueName, MessageCount
        Write-Host "Showing queues for pattern-->$"
        $queues | Format-Table
        Start-Sleep -Seconds $RefreshPerSecond
        }
    }
}