Nested list of group membership for users

I need to list each group (recursively) that an individual AD user is a member of and have the data saved in a CSV file.

Ideally, it will have five columns; username, parent group, sub groups, group type, group scope.

I have found quite a few scripts that people have written, but they either give me the data onscreen and I can't figure out how to export to csv or they export to csv fine, but don't give me the data I need.  

Any help?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
Can you post a link (or the script) that you have that gives you the data you need, but prints to screen?

Will SzymkowskiSenior Solution ArchitectCommented:
This is pretty easy. If you are only looking to find Groups where a specific user is part of use the following one-liner below...

Get-ADPrincipalGroupMembership -Identity user1 | Select Name, GroupScope, GroupCategory | Export-csv "c:\groups.csv" -nti

Open in new window

Thats it.

ppmchgoAuthor Commented:
Thanks all, decided to get this information manually cutting and pasting into a text file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ppmchgoAuthor Commented:
I was not able to solve the problem I was having.  I ended up coming up with a different solution that satisfied what I was looking for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.