scritp to identify the list of DLs not being used in the organization

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?

April 9th, 2015 8:46pm

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 all distribution lists:

Get-DistributionGroup | Select-Object PrimarySMTPAddress | Sort-Object PrimarySMTPAddress | Export-CSV DL-ALL.csv notype

  • Get all distribution lists used over last 30 days:

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

  • Compare preview two files and present list of inactive:

$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.

Free Windows Admin Tool Kit Click here and download it now
April 10th, 2015 3:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics