Note that there are some explanatory texts on larger screens.

plurals
  1. POPowershell with Get-MessageTrackingLog (Exchange 2007)
    text
    copied!<p>I wonder if you can help me. I am trying to extract a list of recipients that have sent emails to themselves (from domain1 to domain2) using get-messagetrackinglog tool within Exchange. My little script seems to work fine with the sender's part, however after a few days of pondering I am unable to make it work with recipients. I suspect that this is because there can be many recipients (as opposed to only one sender) for each email and this requires an array to be assigned to the recipients variable however being new to powershell I am not entirely sure how to do it and how to pipe it through. The logic is the following: </p> <p>a) I want to use split command to segregate all senders (using space delimiter) and fetch them into an array, b) then to detach both sender's and recipients' first parts of addresses from domains using @ delimiter and c) compare their first part of email addresses that I've got (values returned from adam@domain1 and adam@domain2). d) If they match - I need email message results to be exported to .csv. </p> <p>I have got this far:</p> <p>Get-MessageTrackingLog -server "pdnaex1" -EventID "SEND" -start "01/10/2010 00:00:00" -end "31/10/2010 23:59:59" -resultsize Unlimited | Where {[string]$<em>.sender.split("@")[0] -like [string]$</em>.recipients.split("@")[0]} | Select timestamp,@{Name="Sender";Expression={$<em>.sender}},@{Name="Recipients";Expression={$</em>.recipients}},messagesubject | export-csv X:\XXX.csv</p> <p>I know above is incorrect but hope I make my question clear.</p> <p>Any help is greatly appreciated. I suspect my script fails because I fail to populate an array of recipients and compare sender's value against each entry within that array but I cant work out how to do that.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload