PowerShell: Exporting multi-valued attributes using Export-CSV

This post will show you how to force PowerShell to export multi-valued attributes using a process called concatenation (joining). Without concatenation, the export of multi-value properties will not be successful when using the Export-CSV cmdlet, even if the multivalued property only contains a single value.

The Problem:

You attempt to export a multi-valued attribute using Export-CSV and you do not get the results you expect:

The Fix:

You will need to tell PowerShell that you want to concatenate the multiple values contained in the attribute and export them as a single value.

To do this, you will need to use this join command:

@{Name='AttributeName';Expression={[string]::join(";", ($_.AttributeName))}}

Using this join command will tell PowerShell to take every value which is present in the multivalue attribute and join using “;” as a separator. When you re-run your Export-CSV command, you will be able to see all of the values which are present in the multi-valued attribute!

Leave a Reply