Recently I was taking an inventory of Distribution Lists in my messaging infrastructure, which lead me to take an additional step to look at the statistics about the total number of members and the usage of each group. As you would be wondering, it wouldn’t be as easy as we think if we plan to achieve it without a script. Here is one simple script, which let you extract the DL usage statistics with the following information,
- The total number of users in each Distribution Group
- The total number of times the group has used in the past number of days
Most Exchange Server Administrators keep the tracking log retention period as 30 or 60 days. Which means you will only be able to extract usage statistics for the past number of days equal to the message tracking log retention.
Permissions Required: You need to login as Server Admins to get the result or a user who has access to message tracking and Get-TransportServer cmdlet, as the script looks for all transport servers.
You can run the script with or without specific parameters,
Examples,
.\DLStatistics.ps1 [Get you ALL the DL Information with members and usage statistics for last 7 days]
.\DLStatistics.ps1 -Days [Usage Days] -filePath [Give the report Path]
e.g. {.\DL_Usage_Stats.ps1 -Days 1 -filePath C:\scripts\Dev\}
Default File Path is C:\Scripts and the Default usage days is 7 days
Though the script can be run with n number of days duration, I suggest you to run it for a week to get a report faster. The following information will give you a fare idea about the total time the script takes to complete,
Total Number of Groups = ~100
Total Tracking Log Size (all servers) = 8GB
Total time taken = 1- 2 hours.
Once you test the script succesfully, I suggest you to write a batch file and schedule it to run every week so that you can create statitical information for longer periods.
The script can be easily modified to include general DL property field as per your requirements, add additional properties just after the following section similar to below,
Ensure you keep the format similar to above, which should avoid any confusion at the end. It is important for you to know the Distribution Group property field name such as alias,ManagedBy etc. Get-DistributionGroup command can help you get all field names.
Share your comments to improve the script to match the regular requirements.
-Praveen