Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need assistance on getting a powershell script that would enable me pull data of all AD users and their various group they belong to .csv file.

share|improve this question

First of all, get the Quest ActiveRoles Server Commandlets here.

Then the following script should give you a start. I am using Excel to store the info, which you can save as a .csv file. Makes it a little easier with the looping and saving of values.

$a = New-Object -comobject Excel.Application
$a.visible = $True 

$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1)  = "Users and Groups Report"
$c.Cells.Item(1,2)  = Get-Date
$c.Cells.Item(2,1) = "User"
$c.Cells.Item(2,2) = "Groups"

$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.Font.Size = 14

$introw = 3

$users = Get-QADUser -SizeLimit $howmanyusersdoIwanttoget

foreach ($user in $users)
    $c.Cells.Item($introw,1) = $user.DisplayName
    $introw +=1

    $groups = Get-QADGroup -ContainsMember $user
    foreach ($group in $groups)
    $c.Cells.Item($introw,2) = $group.CanonicalName
    $introw +=1

You should be able to tune this up to meet your exact needs hopefully.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.