Hi,@Roger Roger
Thanks for posting your question in the Microsoft Q&A forum.
- First, ensure you have the necessary permissions to perform these actions and that you're connected to your Exchange server or Office 365 via PowerShell.
- Import the CSV file containing the Distribution Lists using the
Import-Csv
cmdlet:
$DLs = Import-Csv -Path "C:\Path\To\Your\File.csv"
- Iterate over each Distribution List in the CSV and retrieve the necessary information. You can use the
Get-DistributionGroup
andGet-DistributionGroupMember
cmdlets to get the details:
$DLInfo = foreach ($DL in $DLs) {
$DLName = $DL.DLList
$Members = Get-DistributionGroupMember -Identity $DLName -ResultSize Unlimited
$DLSettings = Get-DistributionGroup -Identity $DLName
$MemberCount = $Members.Count
$DeliveryManagement = $DLSettings.ManagedBy
$SenderRestrictions = $DLSettings.AcceptMessagesOnlyFrom
[PSCustomObject]@{
DLName = $DLName
MemberCount = $MemberCount
DeliveryManagement = if ($DLSettings.RequireSenderAuthenticationEnabled) {
"Only allow messages from people inside my organization"
} else {
"Allow messages from people inside and outside my organization"
}
SpecifiedSenders = $SenderRestrictions -join ", "
}
}
- Finally, export the gathered information to a new CSV file using the
Export-Csv
cmdlet:
$DLInfo | Export-Csv -Path "C:\Path\To\Your\ExportedFile.csv" -NoTypeInformation
Here are my tests:
The result of exporting the file:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.