Register
: :
Login
Home
Forums
Blogs
Podcast
Directories
Scripts
Downloads
Community
User Group Support
Learning Resources
We have a new sponsor! Introducting
Pragma Systems
. See the home page for details.
Unanswered
Active Topics
Forums
Search
Members
Forums
>
Using PowerShell
>
Peer Review
Timespan SMTP Received headers
Last Post 16 Feb 2009 07:43 PM by
mjolnir
. 0 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
mjolnir
New Member
Posts:19
16 Feb 2009 07:43 PM
Reads an SMTP header, and shows the MTA's it passed through, in chronological order, and calculates and displays the latency between each MTA.
$hdr_txt = gc ./hdr.txt
$rec_hdr_regex = [regex]"^Received\:\sfrom\s+(.+)\s+(.+)\s+by(.+)\s+(.+)\swith\s+(.+)\;\s+(.+\d{4})"
$from_hdr = $hdr_txt | select-string "^From\:\s.+$"
$rec_block = $hdr_txt[0..$($from_hdr.linenumber -2)]
$rec_lines = $rec_block | select-string "^Received\:\sfrom"
$sent_hdr = $hdr_txt | select-string "^Date\:\s.+$"
$sent_hdr.line -match "^Date\:\s(.+)$" > $nul
$sent_ts = [datetime]$matches[1]
foreach ($rec_line in $rec_lines[1..$($rec_lines.count -1)]){
$rec_block[$rec_line.linenumber -1] = "~" + $rec_line.line
}
$rec_hdrs = $([string]$rec_block).split("~")
Write-host "`nMessage sent $($sent_ts)`n"
$i = $rec_hdrs.count -1
$last_ts = $sent_ts
while ($i -ge 0) {
$rec_hdrs[$i] -match $rec_hdr_regex >$nul
$rec_ts = [datetime]$matches[6]
$latency = $rec_ts - $last_ts
$last_ts = $rec_ts
write-host "latency is $($latency.totalseconds) seconds`n"
write-host $matches[1] $matches[2]
$i--
}
Write-host "`nMessage received $($last_ts)"
write-host "Total time is $($($last_ts - $sent_ts).seconds) seconds.`n"
You are not authorized to post a reply.
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
Forums
>
Using PowerShell
>
Peer Review
Active Forums 4.1
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008