Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm trying to export all the members of all the DLs within an OU (either to a single file that's categorized or individual files).

I tried to use:

csvde -f "C:\Documents and Settings\root\Desktop\AD Export\DL Export\DL.txt" -r "OU=DLs,OU=Personnel,DC=csi,DC=org" -l "cn,mail"

but that only works for individual DLs and there are a lot to input each time.

Any help on getting this done in the most efficient pattern would be helpful.

share|improve this question

I grabbed this PS script online somewhere earlier this year to do something similar. Hope it helps. I can't give credit to who created it since it isn't in the script and I can't remember where I found it at this point.

$saveto = "C:\\listmembers.txt"

Get-DistributionGroup | sort name | ForEach-Object {

    "`r`n$($_.Name)`r`n=============" | Add-Content $saveto
    Get-DistributionGroupMember $_ | sort Name | ForEach-Object {
        If($_.RecipientType -eq "UserMailbox")
                $_.Name + " (" + $_.PrimarySMTPAddress + ")" | Add-Content $saveto
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.