0

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.

0

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
            }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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