There's more...

One of the most common problems that Exchange administrators run into with Export-CSV is when exporting objects with multi-valued properties. Let's say we need to run a report that lists each mailbox and its associated email addresses. The command would look something like the following:

    Get-Mailbox | `
      Select-Object Name,EmailAddresses | `
        Export-CSV c:\report.csv -NoType  

The problem here is that each mailbox can contain multiple email addresses. When we select the EmailAddresses property, a multi-valued object is returned. The Export-CSV cmdlet does not understand how to handle this, and when you import the CSV file in PowerShell, you'll end up with a CSV file that looks like the following:

Looking at this screenshot, ...

Get Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.