PowerShell Script to Perform Message Trace By Subject

Script that allows you to search on a subject or variants of a subject going back X number of days. The output is logged to a CSV file showing the details of the trace log entry.

 
 
 
 
 
5 Star
(1)
9,247 times
Add to favorites
Office 365
4/30/2016
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Message Count
    1 Posts | Last post December 01, 2018
    • When the script finishes, it outputs "X Entries Found & Logged in c:xyz". I have it saying 0 entries, but in the output file there is one message, so I think there is an error in the counting logic somewhere. Otherwise, the script works great and is exactly what I need. Thank you.
      
  • get a date error
    2 Posts | Last post October 27, 2016
    • Cannot convert value "16/08/2016 15:28" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
      At C:\O365_Scripts\Get-MessageTraceBySubject.ps1:45 char:1
      + [DateTime]$DateEnd = Get-Date -format g
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : MetadataError: (:) [], ArgumentTransformationMetadataException
          + FullyQualifiedErrorId : RuntimeException
      
      You cannot call a method on a null-valued expression.
      At C:\O365_Scripts\Get-MessageTraceBySubject.ps1:46 char:1
      + [DateTime]$DateStart = $DateEnd.AddDays($Days * -1)
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
    • Change this line:
      [DateTime]$DateEnd = Get-Date -format g
      
      To this:
      [DateTime]$DateEnd = Get-Date