I have become decent at finding the AD data I need but when it comes to creating a spreadsheet with the information I find my knowledge totally inadequate to do what I want to do. I am hoping for some quick help and some helpful URL’s.
When I run "Get-aduser MyID -Properties * | FL Name, Memberof " the memberof field has over 100 entries in curly braces separated by commas.
I would like to end up with a spreadsheet with my name in one column and then another column of the 100+ groups, then the next users name, his groups etc.
I have looked at Format-List, and tried Exportto-csv with no luck, what is the best way to do this?
That’s because MemberOf is a collection of objects, not just a simple value; when asked to display a collection in a list or table, PowerShell can’t create a sub-list or sub-table, so it does the curly bracket thing.
There’s no straightforward way to get what you want using what’s built into the shell. You’d have to code up something custom.
Calculated Expression
Loop through MemberOf
Split the CN into an array
Get the first index (e.g. CN=MyGroup)
Replace CN= with nothing, basically strip off CN=
And finally Join the returned array with a semicolon…