How to export a detailed list of Active Directory users' "Member of" tab?

I am currently in the process of restructuring the Active Directory user list of the company I'm working for, and the person who did it did an awful job, and is of course, not working here anymore.

My question is the following: I want to have an Excel spreadsheet (ideally) containing all the information contained in the "Member of" tab of a user chart.

I have tried creating a query, but the result only gives me a list of users that are a "member of" something, not the actual content of the "member of" tab.

Is there a way to do this, either through command prompt or directly from Active Directory?

Fair warning: I know nothing about VBS and Powershell.


Solution 1:

If you want to get a user's group memberships, run this PowerShell command:

Get-ADPrincipalGroupMembership $Username | Select Name | out-file "filepath" where you want the document saved, including the name you want the document"

Where $Username is the name of the user you're querying.

Solution 2:

I have this, you will need to learn a bit of PowerShell to have it dump to a CSV, right now it just dumps to a text file.

$users = Get-ADUser -Filter * -Properties * -SearchBase "OU=something,DC=domain,DC=net"
foreach ($user in $users) {
    $file = $user.Name + '_ACL'        
    (Get-ADUser –Identity $user –Properties MemberOf).MemberOf -replace '^CN=([^,]+),OU=.+$','$1' | Out-File c:\PSResults\$file.txt
    }

I never took the time to get it working for CSV output as this did what I needed.

-- If you want it to export to a csv, just change the out-file path to the path where you want it to be saved, plus the name of the document.csv, for example, out-file C:\PSResults\$file.csv would export to a CSV named $file