Exchange mailbox export getting strange data

I have a script that does Exchange discovery & then exports to a .csv file.

The script is hundreds of lines long but the relevant part is:

$global:LocalMailboxes = Get-Mailbox -resultsize unlimited -ErrorAction Stop
$global:LocalMailboxes | Export-CSV $global:logpath\Mailboxes_Export_$(Get-Date -UFormat %m-%d-%y_%H-%M-%S_%Z).csv -NoTypeInformation -Encoding UTF8 -ErrorAction Stop

The problem is in some of the columns in the .csv file I don’t receive the expected value.

For the emailaddress column I get:


Here is another example from the AcceptMessagesOnlyFrom column:


Most of the columns have the correct values but about 25% do not. My question is how do I expose these missing values in my .csv export?

That’s because the data in those columns is not a single value, but rather a collection of objects - e.g., more than one Proxy Address. CSV isn’t designed to handle that kind of hierarchy - they’re ‘flat file’ format.

You could potentially rig something, depending on what you want those multiple-value columns to look like, but it won’t be a simple Export-CSV anymore. You’re just asking more from CSV than it’s designed to deliver :(.