Powershell Script to report on Exchange 2010 Distribution Lists

This powershell script allows you to create a report for a bunch of distribution lists that match a certain criteria. In an example here, if you want to search your entire exchange organization for all DLs (static and dynamic) that contain the word “sales”, the script would return the following information.

  1. The name of the DL.
  2. Type of DL (Static or Dynamic)
  3. Number of members.
  4. Display Name of members.
  5. Title of members.

Here’s the script:

$searchterm = "sales"

$DistListSearch = Get-DistributionGroup | where-object { $_.DisplayName -like "*$searchterm*" }
$DistListSearch | foreach {
	$DistGrp = $_
	$DistGrpCount = (Get-DistributionGroup $DistGrp | Get-DistributionGroupMember).count
	"$DistGrp - Total Members = $DistGrpCount - Static Distribution List"
	Get-DistributionGroup $DistGrp | Get-DistributionGroupMember | ft Name, Title

$DynDistListSearch = Get-DynamicDistributionGroup | where-object { $_.DisplayName -like "*$searchterm*" }
$DynDistListSearch | foreach {
	$DynDistGrp = $_
	$DynDistGrpCount = (Get-Recipient -RecipientPreviewFilter $(Get-DynamicDistributionGroup -Identity $DynDistGrp).RecipientFilter -ResultSize Unlimited).count
	"$DynDistGrp - Total Members = $DynDistGrpCount - Dynamic Distribution List"
	Get-Recipient -RecipientPreviewFilter $(Get-DynamicDistributionGroup $DynDistGrp -ResultSize Unlimited).RecipientFilter | ft Name, Title

1 Comment

thanks a ton for your valuable script. I am in process to identifying the manager name by sending email to each DL Manually with below template.

DL NAME DISPLAY NAME E-MAIL ID members managed By groupType

my concern is to fatch the below details by powershell or vbscript

2. smtp of DL
3. members
4.Type of DL (Static or Dynamic)
5.Number of members.
6.Display Name of members.
7.Title of members.
8. group Type

1. output file should / would be as per above if possible.
2. and is there any possibility to send mail automatically to the DL whereas manager name is missing by mail merge/PowerShell/etc.

please share if you have any idea on this.

many thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *