
Hey everyone, how are you doing? So today’s topic is about how to capture last usage of distribution list. We encounter when we need to do clean up on the groups but imagine if you have thousand of groups that you have to check with the owners whether that the group is in use/active, sounds ridiculous right?
So I came across with this request and manage to found a very good reference on achieving this request.
Make sure you have PowerShell on your workstation to get the following result.
If you do not have appropriate permission to run the following command, below reference on how to get it work. If you have the appropriate permission or this is not your first time using PowerShell, then you can just launch your PowerShell as usual.
#Import the module Import-Module ExchangeOnlineManagement #Connect to Exchange Online Connect-ExchangeOnline -Credential $usercredential #Retrieve list of distribution list $DistributionList = Get-DistributionGroup -ResultSize unlimited #Get the message trace function to capture the last usage, a delay is needed to not stress of the throttling $DistributionList | %{Get-MessageTrace -RecipientAddress $_.primarysmtpaddress ; write-host (“Processed Group: ” + $_.primarySMTPAddress) ; Start-Sleep -Milliseconds 500} | export-csv -Path C:\<filename>.csv –Append
References: