hi There,
We would like to identify the list of DLs not being used (no emails received in last 6 months by this DL) in our organization.
Can anyone help me by providing the script or the method to prepare the list?
Technology Tips and News
hi There,
We would like to identify the list of DLs not being used (no emails received in last 6 months by this DL) in our organization.
Can anyone help me by providing the script or the method to prepare the list?
Hi,
The following PowerShell commands will generate a list of distribution groups that have received mail in the last 30 days. The second command pulls data from the Exchange Tracking Logs which only keep 30 days worth of data by default.
The following command gets the logging information needed from server.
Get-TransportService Identity server name | fl *messagetracking*
The following command sets the Log Directory size to 3GB
Set-TransportService -Identity server name -MessageTrackingLogMaxDirectorySize 3000MB
The following command sets the Max Age of logs from 30 days to 90 days
Set-TransportServive -Identity server name -MessageTrackingLogMaxAge 90.00:00:00
Get-DistributionGroup | Select-Object PrimarySMTPAddress | Sort-Object PrimarySMTPAddress | Export-CSV DL-ALL.csv notype
Get-MessageTrackingLog -Server -EventId Expand -ResultSize Unlimited |Sort-Object RelatedRecipientAddress | Group-Object RelatedRecipientAddress |Sort-Object Name | Select-Object @{label=PrimarySmtpAddress;expression={$_.Name}}, Count | Export-CSV DL-Active.csv notype
$file1 = Import-CSV -Path DL-ALL.csv
$file2 = Import-CSV -Path DL-Active.csv
Compare-Object $file1 $file2 -Property PrimarySmtpAddress -SyncWindow 500 |Sort-Object PrimarySmtpAddress | Select-Object -Property PrimarySmtpAddress |Export-Csv DL-Inactive.csv -NoType
Best Regards.