July 28th, 2014
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.
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.