Exchange Server In environments, reporting may be needed to compare or control members for distribution groups. Exchange Admin Center (EAC) Since such detailed reports cannot be created via the system, third-party tools are generally used or PowerShell scripts are preferred.
Reporting on Exchange Server Distribution Groups Using PowerShell
The PowerShell script I prepared produces detailed reports for a specified distribution group or for all distribution groups actively running in the environment. This script saves the members' details as a CSV file.
Availability of Exchange Server Distribution Group Report Script
This PowerShell script is designed to save members of active distribution groups (DLs) in Exchange Server to the specified CSV file. It provides an option for the user to enter the distribution group name and when no group name is entered, it gives a report of all distribution groups active in the environment.
- Function Green: Prints PowerShell output in green.
- Distribution Group Selection: Gets a distribution group name from the user. If left blank, lists all groups.
- Creating a Report: Creates a list with the specified properties for each group and member and saves them to a CSV file.
- File Control: Checks whether the report file was created successfully.
- Creating a Report: For each group and its members, members' name, email address and recipient type information is collected.
- Export to CSV: The collected information is saved as a CSV file in the specified path. This file can be used for analysis and archiving of group structures.
You can access the Exchange Server Distribution Group Reporting Script on Github.
<#
#################################################################################################################
# Yayınlanma Tarihi: 08.12.2022
# Version: 1.0
# Yazar: Cengiz YILMAZ
# MCT, https://cozumpark.com/author/cengizyilmaz
# https://cengizyilmaz.com.tr
# https://msgurusu.com (Azure Blog and News)
# E-posta: [email protected]
##################################################################################################################
.NOTES
# Exchange Server'da aktif çalışan DL içerisindeki üyeleri CSV olarak kaydetmektedir.
# Bir DL hesabı belirtmezseniz ortamda aktif çalışan tüm DL hesaplarını rapor vermektedir.
##################################################################################################################
function Green
{
process { Write-Host $_ -ForegroundColor Green }
}
# Get distribution group name from user
$groupName = Read-Host "Enter distribution group name (leave blank for all groups)"
# If group name is empty, get all groups
if ($groupName -eq "")
{
$groups = Get-DistributionGroup -ResultSize Unlimited
}
else
{
# Get specified group
$groups = Get-DistributionGroup -Identity $groupName
# If group does not exist, show error message and exit
if ($groups -eq $null)
{
Write-Host "Distribution group does not exist" -ForegroundColor Red
return
}
}
# Create report file
$report = @()
# This part will list group memberships and some attributes of members.
$groups | ForEach-Object {
$group = $_
Write-Host "Group: $($group.DisplayName)"
Get-DistributionGroupMember -Identity $group.Name -ResultSize Unlimited | ForEach-Object {
Write-Host " Member: $($_.Name)"
Write-Host " EmailAddress: $($_.PrimarySMTPAddress)"
Write-Host " RecipientType: $($_.RecipientType)"
Write-Host ""
$report += New-Object PSObject -Property @{
Group = $group.DisplayName
Member = $_.Name
EmailAddress = $_.PrimarySMTPAddress
RecipientType = $_.RecipientType
}
}
}
# Export report to CSV file
$report | Export-Csv "C:\DLMember.csv" -NoTypeInformation -Encoding UTF8
# Check if the export file has been created successfully.
$Folder = "C:\DLMember.csv"
if (Test-Path -Path $Folder) {
"Success C:\DLMember.csv"| Green
} else {
"Fail."
}