Ex2016 - Getting message tracking results per recipient using Powershell

davrion 46 Reputation points
2021-07-02T13:28:59.513+00:00

I'm trying to work on a script that will save the message tracking results on a per-recipient basis. I am filtering on the DELIVER event, but users on the same database will show as a collection. What's the easiest way to get the results from the first set of data look like the second set of data, i.e. one entry per recipient? On-prem 2016 CU20

I want to get the data in the form of a hash that can be used elsewhere in the script.

EventID Sender MessageSubject Recipients
DELIVER joe@keyman .com Test Email bob@Company portal .com
DELIVER joe@keyman .com Test Email sue@Company portal .com
DELIVER joe@keyman .com Test Email {pam@constoso.com,bill@Company portal .com,jill@Company portal .com}
DELIVER joe@keyman .com Test Email rick@Company portal .com

EventID Sender MessageSubject Recipients
DELIVER joe@keyman .com Test Email bob@Company portal .com
DELIVER joe@keyman .com Test Email sue@Company portal .com
DELIVER joe@keyman .com Test Email pam@Company portal .com
DELIVER joe@keyman .com Test Email bill@Company portal .com
DELIVER joe@keyman .com Test Email jill@Company portal .com
DELIVER joe@keyman .com Test Email rick@Company portal .com

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,369 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. KyleXu-MSFT 26,211 Reputation points
    2021-07-05T02:46:24.123+00:00

    @davrion

    You can use script below to expand {pam@constoso.com,bill@Company portal .com,jill@Company portal .com}:

    $temps = Get-TransportService | Get-MessageTrackingLog -Sender User@domain.com -MessageSubject "test7/5" -EventId DELIVER  
      
    Foreach ($temp in $temps) {  
        $i = 0  
        while ($temp.Recipients[$i] -ne $null) {  
            Write-host $temp.EventID $temp.Sender $temp.MessageSubject $temp.Recipients[$i] $temp.Timestamp  
            $i++  
        }  
    }  
    

    By the way, Exchange Q&A forum doesn't support writing script according to needs so far. If you have more requirements about scripts, I suggest you open a ticket to Microsoft to get a more professional script.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.