Author Posts

January 1, 2012 at 12:00 am

by Heine at 2013-02-27 02:20:19

Hi

Does anyone know how I can get a list from the messagetrackinglog where an email send to multiple recipients is listed on separate lines with on recipient on each?

I'm working with the following objects: |Select-object Timestamp, Sender, Recipients, MessageSubject |

by poshoholic at 2013-02-27 07:20:53

So you are reading the contents of the tracking log, and the Recipients property has a newline-delimited list of email addresses? If that's an accurate assessment, you could replace your Recipients property name above with this:
@{Name='Recipients';Expression={@($_.Recipients -split "`r`n|`r|`n")}}
That tells PowerShell to make the Recipients property of the selected object contain an array of the Recipients property you passed in, split on any newline character combination.

by Heine at 2013-05-03 03:21:21

Hi Kirk

Thanks for the reply.

I'm totally new to Powershell so unfortunately I don't think I understand your question.

But let me try to elaborate a bit on my problem.

I'm working with the below script and it returns the following to me:

#TYPE Selected.Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingEvent
"Timestamp","Source","RecipientCount","Sender","$_.recipients"
"26-02-2013 09:09:49","SMTP","2","yy@X.com","aa@X.com bb@X.com"

What I would like it to return is:

#TYPE Selected.Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingEvent
"Timestamp","Source","RecipientCount","Sender","$_.recipients"
"26-02-2013 09:09:49","SMTP","2","yy@X.com","aa@X.com"
"26-02-2013 09:09:49","SMTP","2","yy@X.com","bb@X.com"

How should I do that ?
____

$EmailDomainOne = "*@X.com*"
$EmailDomainTwo = "*@X.com*"
$startdate = "2/26/2013 9:00am"
$enddate = "2/26/2013 11:00am"
$outputfile = "test1.txt"

get-messagetrackinglog -start $startdate -end $enddate -resultsize unlimited| where {(([string]$_.recipients -like $EmailDomainOne -and [string]$_.sender -like $EmailDomainTwo)) -and (($_.eventid -eq "SEND") )} | Select-object Timestamp, Source, RecipientCount,Sender, {$_.recipients} | Sort-Object -Property Timestamp| export-csv $outputfile -Encoding unicode