Doing some testing today, I needed to check how many emails were sitting in Exchange queues across 6 different transport servers. The queues in question were outbound queues for journaling.
Since the queues on each server have a numeric name that’s of no use for this, I was able instead to search based on the next hop domain. All of our journal queues point to smart hosts with “journal” in the FQDN.
Here’s how I got the total count of messages sitting in the 6 queues:
Get-TransportServer | Get-Queue | Where-Object {$_.NextHopDomain -like "*journal*"} | Measure-Object -Sum -Property MessageCount
An alternative, which I discovered afterwards, would be to filter directly on Get-Queue instead of piping all of the queues to Where-Object:
Get-TransportServer | Get-Queue -Filter "NextHopDomain -like '*journal*'" | Measure-Object -Sum -Property MessageCount
Further Reading: