When working with PowerShell to export information from Exchange, I ended up with unreadable data in my csv-file when i tried to export sync-times for mobile devices.
Get-Mailbox -OrganizationalUnit Accounting | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity | Format-Table Identity,LastSuccessSync | Export-Csv filename.csv
This will give you output like this:
#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
ClassId2e4f51ef21dd47e99d3c952918aff9cd,"pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
033ecb2bc17a4d43c5ef94ed5a35d272,,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo",
be211fe47d09416682f34cb69c38b8c1,,,,,
Not very helpful..
This is because the default Output for PowerShell will format this for you, but Export-Csv will not.
This is fixed by replacing Format-Table with the Select-Object cmdlet like this:
Get-Mailbox -OrganizationalUnit Accounting | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity | Select-Object Identity,LastSuccessSync | Export-Csv filename.csv
That will give you the output you expected