Skip to content

Instantly share code, notes, and snippets.

@lordmuffin
Created May 30, 2014 17:00
Show Gist options
  • Save lordmuffin/7f8841a0eb1bb98bf354 to your computer and use it in GitHub Desktop.
Save lordmuffin/7f8841a0eb1bb98bf354 to your computer and use it in GitHub Desktop.
## Get all distribution list email addresses and output to csv
$dgs = Get-DistributionGroup -ResultSize Unlimited | Select DisplayName, EmailAddresses
$foreach = Foreach($dg in $dgs) {
New-Object PSObject -Property @{
DisplayName = $dg.DisplayName
EmailAddresses = [String]$dg.EmailAddresses
}
}
$foreach | Select DisplayName, EmailAddresses | Export-Csv -Path C:\Scripts\dg-email-addresses.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment