search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
How to get queue count on Exchange Server with PowerShell
Posted in Exchange Server, Windows Powershell | 2 Comments | 13,172 views | 22/05/2013 16:45

You can get ready and retry queue’s of Exchange Server with this script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$ExchangeHost = "ExCas01"
$ExchangeServer = Get-ExchangeServer -Identity $ExchangeHost
 
# Integers
[int]$ExchangeActiveConnections = 0;
[int]$ExchangeRetryQueue = 0;
[int]$ExchangeMessageQueue = 0;
[int]$ExchangeActiveQueue = 0;
[int]$HostMessageQueue = 0;
[int]$HostRetryQueue = 0;
 
# Get Mail Queue
if ($ExchangeServer.IsHubTransportServer -eq $True)
{
	# Message Queue
	$MessageQueue = Get-Queue -Server $ExchangeHost | Where {$_.Status -eq "Ready" -and $_.MessageCount -gt "0"}
 
	# Sum Message Queue
	Foreach ($Queue in $MessageQueue)
	{
		[int]$HostMessageQueue = [int]$HostMessageQueue + [int]$Queue.MessageCount
	}
 
	# Retry Queue
	$RetryQueue = Get-Queue -Server $ExchangeHost | Where {$_.Status -eq "Retry" -and $_.MessageCount -gt "0"}
 
	# Sum Retry Queue
	Foreach ($Queue in $RetryQueue)
	{
		[int]$HostRetryQueue = [int]$HostRetryQueue + [int]$Queue.MessageCount
	}
 
	# Exchange Queue
	[int]$ExchangeRetryQueue = [int]$ExchangeRetryQueue + [int]$HostRetryQueue
	[int]$ExchangeMessageQueue = [int]$ExchangeMessageQueue + [int]$HostMessageQueue
	[int]$ExchangeActiveQueue = [int]$ExchangeActiveQueue + [int]$HostRetryQueue + [int]$HostMessageQueue
}

You can add multiple Exchange hosts to an array, it’ll just query Hub Transport servers. It only support Exchange Server 2010.


Comments (2)

NeWay Technologies – Weekly Newsletter #44 – May 24, 2013 | NeWay

May 25th, 2013
18:00:58

[…] How to get queue count on Exchange Server with PowerShell – 22-May-2013 […]


Galvanizli Boru

September 2nd, 2015
13:08:26

Yusuf Bey Merhaba,
Paylaşmış olduğunuz bu script son derece işime yaradı.
Exchange scriptleri ile alakalı olarak sitenizi sürekli takip ediyor olacağım.
Çok teşekkür ederim,
İyi çalışmalar



Leave a Reply