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'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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.