Find all groups a member belongs to and Export to CSV - TEST

This is a test -

To retrieve and list all of the groups a user belongs to in Active Directory you can use the commands Get-ADPrincipalGroupMembership. This is handy but often a user has far too many groups to simply list in PowerShell. The code below will show a few ways to get this data.

Get-ADPrincipalGroupMembership -Identity UserId

This will list every group that the user belongs to but it will just zip by on the screen. I know you can scroll, but what fun is that. Try the following code to create a formatted csv file .

Get-ADPrincipalGroupMembership -Identity UserId |
Export-Csv C:\Users\Player1\Desktop\gmembership.csv

Shiny eh? You can also output this to a text file, but the data is trimmed and if you have long group names it wont be as easy to use. See the code below.

Get-ADPrincipalGroupMembership -Identity UserId |
Out-File -FilePath C:\Users\Player1\Desktop\gmembership.txt

Workable but I prefer the csv, though, I am addicted to Excel in most cases.