
$ExchangeServers = Import-Csv C:\Scripts\Input\computers.csv -ErrorAction Continue -Verbose | % {

#$ExchangeServers | % {Get-Message -Filter {FromAddress -like "*@ons.gov.uk"} | Format-List}

  Get-Message -Filter {status -eq "retry"} | select fromaddress, queue 

 Get-Message -Filter {FromAddress -like "*@ons.gov.uk"} | Format-List

 Get-Message -Filter {subject -like "*"} | Format-List

#$ExchangeServers | % {Get-Messages -Filter Subject -like "*t*"}
 

#Get-QueueDigest -Server $ExchangeServers -Include external



#Get-Message -Filter {Status -eq "Retry"} 

}

<#
Commands
Resume-Queue 
Get-Message
Retry-Queue  # $ExchangeServers | % {Retry-Queue -Filter {status -eq "retry"} | select fromaddress, queue}

Suspend-Queue 

# Filter
•
DeliveryType
LastError
NextHopCategory
NextHopDomain
NextHopKey
Status
ServerName




452 4.3.1 insufficient system resources exchange 2013

Get-Message -Filter {subject -like "*test*"} | select subject

Get-Message -IncludeRecipientInfo -Filter {Status -eq "Retry"} | Format-Table FromAddress,Recipients,Subject,DateReceived


Get-Message -Filter {Status -eq "Retry"} | Retry-Queue

Get-Queue -Identity Submission | Select Identity,Status,MessageCount



############## Get Queue on all exchange servers
Get-TransportServer | Get-Queue

############# Get message on all transport servers
Get-TransportServer | Get-Queue | Get-Message




##########Suspending all the messages on queue
 

Get-Queue | Get-Message | Suspend-Message
 
##########Deleting messages on queue
 

Get-Queue | Get-Message | Remove-Message






###########Message tracking

# Find messages by sender: 

Get-MessageTrackingLog -sender “foo@somedomain.com”
 
# Find messages by recipient: 

Get-MessageTrackingLog -recipients “foo@mydomain.com”
 
# Messages received or messages delivered to the mailbox: You can further separate or constrain these by message received:
 
Get-MessageTrackingLog -sender “foo@somedomain.com” -eventID RECEIVE
 
# and messages delivered to the mailbox 

Get-MessageTrackingLog -sender “foo@somedomain.com” -eventID DELIVER
 
# Start and End date/time: To further constrain these by Start and End times: 

Get-MessageTrackingLog -sender foo@somedomain.com -eventID DELIVER -Start “10/01/2006 9:00AM” -End “10/03/2006 5:00PM”

Sender # E. G................ Get-TransportServer | Get-MessageTrackingLog -sender alberto.igbinedion@ons.gov.uk -eventID DELIVER -Start “16 November 2015 10:06:5” -End “17 November 2015 16:06:5” |FL| Out-File C:\

RRecipients # Or .............Get-MessageTrackingLog -Recipients paul.phelps@ons.gov.uk -eventID receive -Start “16 November 2015 10:06:5” -End “17 November 2015 16:06:5” |FL| Out-File C:\



#Event-Id : BADMAIL, DELIVER, DSN, EXPAND, FAIL, POISONMESSAGE, RECEIVE, REDIRECT, RESOLVE, SEND, SUBMIT, and TRANSFER.
# Source : ADMIN, AGENT, GATEWAY, PICKUP, ROUTING, SMTP, STOREDRIVER

Get-TransportServer | get-messagetrackinglog -EventID "FAIL" -Start “16 November 2015 10:06:5” -End “17 November 2015 16:06:5" | where-object {$_.Source -eq "AGENT"}


####### Calander
Get-TransportServer | Get-MessageTrackingLog -sender marie.burns@ons.gov.uk -Start “16 November 2015 10:06:5” | Where { $_.SourceContext.ToString().Contains("IPM.Schedule.Meeting.Request") -eq $true } | fl | Out-File C:\
OR
Get-TransportServer | Get-MessageTrackingLog -Recipients jeremy.heaven@ons.gov.uk -Start “16 November 2015 10:06:5” | Where { $_.SourceContext.ToString().Contains("IPM.Schedule.Meeting.Request") -eq $true } | fl | Out-File C:\


#>