Why do I get "System.String[]" when using Get-MessageTrackingLog and exporting to a CSV?

by Nuno Mota [Published on 30 Nov. 2011 / Last Updated on 28 Nov. 2011]

Problems using Get-MessageTrackingLog and exporting to a CSV file

Let’s say a user is having problems sending e-mails. You decide to have a look at the Transport Logs to see if there are any clues of what might be happening. So you run the following cmdlet:

 

Get-TransportServer | Get-MessageTrackingLog -ResultSize -Start "11/28/2011" -Sender nuno@letsexchange.com | Select * | Export-Csv D:\Reports\Sent_Nuno.csv -NoType

 

However, you notice that the Recipients and RecipientStatus fields have "System.String[]" instead of the actual recipients or recipient information!

The problem here is that these fields are a collection of objects and, as subject, you have to expand them into a string so they show properly when you pass them to the Export-CSV cmdlet. The easiest way to achieve this is to put them in between {}. Here’s a simple example:

 

Get-TransportServer | Get-MessageTrackingLog -ResultSize -Start "11/28/2011" -Sender nuno@letsexchange.com | Select {$_.Recipients}, {$_.RecipientStatus}, * | Export-Csv D:\Reports\Sent_Nuno.csv -NoType

See Also


See Also

Featured Links