none
Log Output RRS feed

  • Question

  • Looking for a way to output the following Exchange code to a csv file, running into some issues along the way. The following code reads in all servers with Transport Service to scan all message tracking logs, then loops through them with the input. I am only concerned with SEND and DELIVER here, no other event ID's.


    $servers = Get-TransportService | select -ExpandProperty Name
    foreach ($server in $servers)
    {
       Get-MessageTrackingLog -Server $server -Sender user@company.com -Start 2/22/2019 -End 2/26/2019 -ResultSize Unlimited | where {$_.eventid -eq "SEND" -or $_.eventid -eq "DELIVER"}
    }

    What I would like to do is take the final output of this command and feed it to a csv file. The loop is making this a bit tricky.

    • Moved by Bill_Stewart Wednesday, September 4, 2019 6:13 PM This is not "scripts on demand"
    Thursday, February 28, 2019 3:00 AM

All replies

  • Please only post code using the code posting tool provided.

    Get-TransportService |
        ForEach-Object{
            Get-MessageTrackingLog -Server $_.Name -Sender user@company.com -Start 2/22/2019 -End 2/26/2019 -ResultSize Unlimited | Where-Object { $_.eventid -eq "SEND" -or $_.eventid -eq "DELIVER" }
        } |
        Export-Csv logfile.csv -NoTypeInformation
    


    \_(ツ)_/

    Thursday, February 28, 2019 3:18 AM