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

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Exchange Server, Windows Powershell | 2 Comments | 13,048 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.