locked
Exchange 2007 Message Tracking Log Parsing RRS feed

  • General discussion

  • Good Day,

    I am able to get a csv file from the exchange 2007 message tracking log using the Get-MessageTrackingLog cmdlet using exchange management console. Find below a single line from the csv file along with headers;

    Timestamp,ClientIp,ClientHostname,ServerIp,ServerHostname,SourceContext,ConnectorId,Source,EventId,InternalMessageId,MessageId,$_.Recipients,$_.RecipientStatus,TotalBytes,RecipientCount,RelatedRecipientAddress,$_.Reference,MessageSubject,Sender,ReturnPath,MessageInfo 

    "2/27/2012 12:10:38 PM",192.168.1.100,exchange1.test.local,192.168.1.100,exchange1,,,STOREDRIVER,RECEIVE,9,<user2@test.com",,7988,2,,,"FW: New Domain ",testuser@iprocess.com,testuser@iprocess.com,04I:

    Please excuse the wrapping. If you notice, the "$_.Recipients" field has multiple email addressess when the email is sent to multiple users. What we'd like to do is, replicate the entry for each recipient so that the output looks something like this;

    "2/27/2012 12:10:38 PM",192.168.1.100,exchange1.test.local,192.168.1.100,exchange1,,,STOREDRIVER,RECEIVE,9,<",,7988,2,,,"FW: New Domain ",testuser@iprocess.com,testuser@iprocess.com,04I:

    "2/27/2012 12:10:38 PM",192.168.1.100,exchange1.test.local,192.168.1.100,exchange1,,,STOREDRIVER,RECEIVE,9,<user2@test.com",,7988,2,,,"FW: New Domain ",testuser@iprocess.com,testuser@iprocess.com,04I:

    The recipients are delimited by a single space.

    Im beginning to dwelve into powershell, though Im no expert. Any help on this would be greatly appreciated.

    Regards

    Crackinspine...

    Friday, March 16, 2012 8:41 AM

All replies

  • Although I am no expert in PowerShell either, I have done a bit of looping with CSV files.  A possible solution to this would be to create a loop off that one variable.  if it were stored in an array you could do something like this:

    $log = Import-Csv c:\messagetrackinglog.csv
    foreach ($line in $log)
    {
    foreach ($Address in $line.Recipients){
    write-host $line.timestamp,$line.ClientIP,$line.ClientHostname,$Address
    }
    }

    It may need some tweaking, but this should give you a good start.


    JAUCG

    Sunday, April 22, 2012 4:26 PM