I've searched far and wide today to no avail. The basic issue is someone sent an email to a DL, and I want a list of people who received this email. Simple right? While Powershell is AWESOME.. some simple things turn into nightmares.. case in point. Here is my powershell command..
Get-ExchangeServer | where {$_.IsHubTransportServer -eq "true"} | sort-object Name | get-messagetrackinglog -ResultSize unlimited -sender john@contoso.com -EventID "deliver" -Start "05/14/2013 10:00:00 AM" -End "05/14/2013 12:00:00 PM" -messagesubject "I can't figure this out" | select-object timeStamp,eventid,ServerHostName,Sender,@{Name=”Recipients”;Expression={[string]::join(";", ($_.recipients))}} ,MessageSubject | Export-csv c:\sent1.csv -notypeinformation
This works, exactly as I expect but here is the BIG problem. #_.recipients is a string value, and this email was sent to A DL, with nested groups. So when I open the results, there are rows that have multiple recipient smtp addresses in the same row. So the output looks like this in Excel. Normally this works fine, but I think the issue is that this was a DL, and in the output CSV I see rows that contain 1 recipient and others may contain 20 on the same row. Any suggestions on how I can fix this?
Timestamp SenderRecipients Recipients
5/14/2013 10:46 john@contoso.com jim@consoto.com;jack@contso.com;bob@contoso.com
What I want is this..
Timestamp SenderRecipients Recipients
5/14/2013 10:46 john@contoso.com jim@consoto.com;
5/14/2013 10:46 john@contoso.com jack@contso.com;
5/14/2013 10:46 john@contoso.com bob@contoso.com