Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from superuser.com May 23 at 13:13

This question came from our site for computer enthusiasts and power users.

add comment

2 Answers 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.

share|improve this answer
    
Just saw that Josh R beat me to it. His is simpler as well. –  mortenya May 22 at 21:52
1  
However, yours will work on lower versions of PowerShell. –  Josh R May 22 at 21:53
    
True, I have had to keep that in mind when I share scripts in my group, as I'm the only one with PowerShell experience, and as such the only one who ever upgraded past 2.0 –  mortenya May 22 at 21:55
    
Now that I think about it, I believe Get-ADPrincipalGroupMembership is in 2.0. Not sure what I was thinking. –  Josh R May 22 at 21:59
    
Thanks both of you for the reply. I'll try Josh R's one tomorrow while at work, since it actually looks a lot simpler. Unless I'm misunderstanding, I'll have to generate this query for each and every user on my domain ? Or if I were to use Mortenya's one, it would generate a complete list the first time ? Just want to make sure I understand correctly! :) –  Alex May 23 at 2:24
add comment

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

Get-ADPrincipalGroupMembership Username | Select Name

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.