Exchange Management Shell – List All Distribution Lists and Members

ByChris Hall

Exchange Management Shell – List All Distribution Lists and Members

The below is a script written to output all Distribution Lists (DL) and DL Members to a CSV File.

Note that the variable set in the first line of the script is the CSV Output Location and you should change the line with ‘RemoteExchange.ps1’ to the location of your Exchange directory.

set-variable -name exportCSVFileLocation -value “C:\temp\Export.csv”
Remove-Item “$exportCSVFileLocation”
Cls
echo “”
echo “**********************************************”
echo “Export All Distribution Lists and Users to CSV”
echo “**********************************************”
echo “”
echo “CSV File Output Location: $exportCSVFileLocation”
echo “”
echo “Exporting, Please wait…”
echo “”
. ‘C:\Program Files\Exchange Server\V15\bin\RemoteExchange.ps1’
Connect-ExchangeServer -auto | out-null
foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | sort displayname | select-object displayname,recipientType,@{Label=”Group Name”;Expression={“$group”}} | export-csv -append “$exportCSVFileLocation”}
echo “”
echo “Export Complete”
echo “”
pause

About the author

Chris Hall administrator

Leave a Reply