$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
}
}
}
Reference:
Export Distribution List Members
http://community.spiceworks.com/scripts/show/1388-export-distribution-list-members
No comments:
Post a Comment