Message Tracking in Exchange 2013 changed significantly. In previous versions there was a simple gui driven process to do quick, basic “track & trace” message reporting.
In Exchange 2013, there’s multiple ways to do this common task. Firstly using the Get-MessageTracking PowerShell commandlet, and also by using the Delivery Reports functionality baked into the EAC. In my opinion, neither of these are particular efficient for quick tracking tasks, particularly for staff who are not particularly savvy/comfortable with using PowerShell.
For this reason, I wrote a small PowerShell script to wrap the Get-MessageTrackingLog operation into a friendly, easy to use GUI, with the output straight into a convenient Out-gridview pivot that can be nicely filtered. Upon executing the script, the following form is presented;
There are 2 variables that need to be set;
$msxserver is the name of your CAS server & $suffix is the smtp domain of the user.
Details returned can be customised, but I have included: TimeStamp, Sender, Recipients, MessageSubject, EventID, ClientIP, ClientHostname
In the first field, enter the username (this will automatically be concatenated to the $suffix variable)
Enter the FROM and TO dates (START and FINISH). Checking either the Sender or Recipient checkboxes determines if the tracking log is based on the username being the Recipient or Sender in the search context.
The output; Clear, concise and easily manipulated.
…and here’s the script in it’s entirety;
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# Simple Powershell form to 'wrap' the Exchange Message Tracking into a GUI for general ease of use # change $msxserver to your exchange server, change $suffix to your fqdn [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") New-Variable -Name username -Option AllScope New-Variable -Name RecipientCheckbox -Option AllScope New-Variable -Name SenderCheckbox -Option AllScope New-Variable -Name emaildatefrom -Option AllScope New-Variable -Name emaildateto -Option AllScope $msxserver = "yourcasserver.domain.com" $suffix = "@domain.com" # Create the form $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Exchange Message Tracking V0.1" $objForm.Size = New-Object System.Drawing.Size(400,300) $objForm.StartPosition = "CenterScreen" # Create username input box $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Size(10,20) $objLabel1.Size = New-Object System.Drawing.Size(280,20) $objLabel1.Text = "Enter the email address to track;" $objForm.Controls.Add($objLabel1) $objTextBox1 = New-Object System.Windows.Forms.TextBox $objTextBox1.Location = New-Object System.Drawing.Size(10,40) $objTextBox1.Size = New-Object System.Drawing.Size(260,20) $objTextBox1.TabIndex = 0 $objForm.Controls.Add($objTextBox1) # Create FROM date box $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Size(10,70) $objLabel2.Size = New-Object System.Drawing.Size(280,20) $objLabel2.Text = "Enter the FROM date; format MM/dd/yyyy hh:mm:ss" $objForm.Controls.Add($objLabel2) $objTextBox2 = New-Object System.Windows.Forms.TextBox $objTextBox2.Location = New-Object System.Drawing.Size(10,90) $objTextBox2.Size = New-Object System.Drawing.Size(260,20) $objTextBox2.TabIndex = 1 $objForm.Controls.Add($objTextBox2) # Create TO date box $objLabel3 = New-Object System.Windows.Forms.Label $objLabel3.Location = New-Object System.Drawing.Size(10,120) $objLabel3.Size = New-Object System.Drawing.Size(280,20) $objLabel3.Text = "Enter the TO date; format MM/dd/yyyy hh:mm:ss" $objForm.Controls.Add($objLabel3) $objTextBox3 = New-Object System.Windows.Forms.TextBox $objTextBox3.Location = New-Object System.Drawing.Size(10,140) $objTextBox3.Size = New-Object System.Drawing.Size(260,20) $objTextBox3.TabIndex = 2 $objForm.Controls.Add($objTextBox3) #Create a checkbox for Recipient $RecipientCheckbox = New-Object System.Windows.Forms.Checkbox $RecipientCheckbox.Location = New-Object System.Drawing.Size(10,180) $RecipientCheckbox.Size = New-Object System.Drawing.Size(100,20) $RecipientCheckbox.Text = "Recipient" $RecipientCheckbox.TabIndex = 4 $objForm.Controls.Add($RecipientCheckbox) #Create a checkbox for Sender $SenderCheckbox = New-Object System.Windows.Forms.Checkbox $SenderCheckbox.Location = New-Object System.Drawing.Size(110,180) $SenderCheckbox.Size = New-Object System.Drawing.Size(160,20) $SenderCheckbox.Text = "Sender" $SenderCheckbox.TabIndex = 5 $objForm.Controls.Add($SenderCheckbox) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(120,220) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$username=$objTextBox1.Text;$emaildatefrom=$objTextBox2.Text;$emaildateto=$objTextBox3.Text;$objForm.Close()}) $OKButton.TabIndex = 9 $objForm.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(195,220) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $CancelButton.TabIndex = 10 $objForm.Controls.Add($CancelButton) $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$username=$objTextBox1.Text;$emaildatefrom=$objTextBox2.Text;$emaildateto=$objTextBox3.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) # concatenate vars together and run cmdlet $fulladdr = ($username+$suffix) If ($RecipientCheckbox.Checked -eq $true) { Get-MessageTrackingLog -Server $msxserver -Start "$emaildatefrom" -End "$emaildateto" -Recipient $fulladdr |select-object TimeStamp, Sender, Recipients, MessageSubject, EventID, ClientIP, ClientHostname |out-gridview } If ($SenderCheckbox.Checked -eq $true) { Get-MessageTrackingLog -Server $msxserver -Start "$emaildatefrom" -End "$emaildateto" -Sender $fulladdr |select-object TimeStamp, Sender, Recipients, MessageSubject, EventID, ClientIP, ClientHostname |out-gridview } |
Hope it’s useful to someone 🙂
Thanks for the script, I used it today,but I didn’t find an option to provide “Time” in-fact the very first screen shot in your blog didn’t even appeared when I ran the script.
You include the time in the FROM/TO dialog, in one string. If you don’t enter it in the FROM field it starts from 12:00:01am and in the TO field 11:59:50, IIRC.
Did you get an error when you ran it ? I assume you ran it from the Exchange Management Shell or loaded the pssnapin into the reg Powershell session ?
Thanks for the script, I used it today,but I didn’t find an option to provide “Time” in-fact the very first screen shot in your blog didn’t even appeared when I ran the script.
You include the time in the FROM/TO dialog, in one string. If you don’t enter it in the FROM field it starts from 12:00:01am and in the TO field 11:59:50, IIRC.
Did you get an error when you ran it ? I assume you ran it from the Exchange Management Shell or loaded the pssnapin into the reg Powershell session ?
Nice script, thanks for Creating and sharing it.
Thanks Chris
any chance you can double check your code? i’m not super shell savvy but i followed your instructions and ran it on exchange powershell and i get the pop up for the variables but i don’t ever get an out put. Please help.
Hi Clark, if you email me the shot of the popup you’re getting I’ll see what’s up with it and sort for you.
–Brett
any chance you can double check your code? i’m not super shell savvy but i followed your instructions and ran it on exchange powershell and i get the pop up for the variables but i don’t ever get an out put. Please help.
Hi Clark, if you email me the shot of the popup you’re getting I’ll see what’s up with it and sort for you.
–Brett
Works great, sometimes does not pop up results if you run subsequent queries.
Otherwise I love this!
thanks !
You are da bomb, my friend.