Blog » 

Monthly Archives: July 2014

PowerShell : Exporting multi-valued attributes with Export-Csv – how to tame the beast (SysAdmins, rejoice!)

The Scenario:

You want to query AD, Exchange, SharePoint, etc. to quickly retrieve some basic, but really useful information about something really common. Examples: users, sites, etc. And of course you want to export these values to a CSV so you can sort, filter, aggregate, count, etc. in Excel or some similar tool.  One or more of the values that you’ll retrieve – usually the most important ones, in our experience – is not a single value, but instead, a set of values (e.g., a user belongs to multiple groups, or multiple distribution lists.) Easy, right? Not so much.

The problem:

PowerShell queries on fields/objects that naturally yield multiple results don’t return the values when you use the Export-Csv cmdlet, even when the values are displayed in the PowerShell console itself.


Categories: Managed IT Services

Tagged with: