Site icon MxCloudPro

Exchange Mail Queue Management CMDlets

Exchange Mail Queue Management PowerShell CMDlets

Get Message Queue information

Get-transportserver | Get-Queue –SortOrder: -MessageCount

Get Queue Details

Get-Queue –Server <server name> | Sort-Object -Property Messagecount | FT Identity, DeliveryType, NextHopDomain, Status, MessageCount, LastRetryTime, LastError -autosize

Move Messages to Another Working Queue

In the event a Hub Transport server is completely out, you may have the requirement to move all messages in a queue to another Hub Transport server in your organization to ensure the messages are delivered.  How can you do this?

First you need to export all messages in the current queue.  You can do this with the following powershell commands:

$array = @(Get-Message -Queue “QueueName” -ResultSize unlimited)

$array | ForEach-Object {$i++;Export-Message $_.Identity | AssembleMessage -Path (“c:\MailsExport\”+ $i +”.eml”)}

To import the messages into the new Hub Transport server, simply place the .eml files into the Transport Pickup folder.  The new server should immediately start processing the messages.

Get Specific Queue

Get-Queue Server\Queue

Get all Queues and sort by Message Count

Get-TransportServer | Get-Queue -sortorder: -messagecount

Get all Queues with Retry Status sorted by messagecount

Get-TransportServer | Get-Queue -sortorder: -messagecount | where {$_.Status -eq “Retry”} | fl

Get Queues greater than 25

Get-TransportServer | Get-Queue -Filter {MessageCount -gt 25}

Retry Queues where the next hop domain is ‘domain.com’

Retry-Queue -Filter {NextHopDomain -eq “domain.com” -and Status -eq “Retry”}

Resume Queues on Server1 where the next hop domain is ‘domain.com’

Resume-Queue -Server Server1 -Filter {NextHopDomain -eq “domain.com”}

This example suspends processing on all queues on server Server1.contoso.com that have more than 100 messages in the queue.

Suspend-Queue -Server Server1.contoso.com -Filter {MessageCount -gt 100}

This example suspends processing on all queues holding messages for delivery to the domain contoso.com and that currently have a status of Retry.

Suspend-Queue -Filter {NextHopDomain -eq “contoso.com” -and Status -eq “Retry”}

Exit mobile version