How to get a distribution group's utilization report of last 30 days in Exchange Online
Introduction
This script will generate a report about Distribution Group's utilization.
Scenarios
This script is to help Exchange Administrators to generate a utilization report of organization's DG. And this script can generate a report with message details sent or received from a DG.
Script
You can use this script in the following way.
1. Open Windows PowerShell.
2. Type the one command< Script Path> at the Windows PowerShell Console.
For example, type C:\Script\ GetGroupUtilization.ps1
Here are some code snippets for your reference.
Foreach ($Group in $GroupList)
{
foreach($address in $Group.Emailaddresses)
{
if($regexSMTP.Matches($address) -ne "")
{
$PrimaryAdd = $regexSMTP.Matches($address).Value
}
}
$MessageReceivedList = Get-Messagetrace -RecipientAddress $PrimaryAdd -startdate $StartDate -EndDate $EndDate
$MessageSendList = Get-Messagetrace -SenderAddress $PrimaryAdd -startdate $StartDate -EndDate $EndDate
$GroupStatusObject = New-Object PSObject
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Display Name" -Value $Group.DisplayName
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Email Address" -Value $PrimaryAdd
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Received" -Value $MessageReceivedList.Count
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Send" -Value $MessageSendList.Count
$GroupMessageStatus += $GroupStatusObject
}
Foreach ($Group in $GroupList)
{
foreach($address in $Group.Emailaddresses)
{
if($regexSMTP.Matches($address) -ne "")
{
$PrimaryAdd = $regexSMTP.Matches($address).Value
}
}
$MessageReceivedList = Get-Messagetrace -RecipientAddress $PrimaryAdd -startdate $StartDate -EndDate $EndDate
$MessageSendList = Get-Messagetrace -SenderAddress $PrimaryAdd -startdate $StartDate -EndDate $EndDate
$GroupStatusObject = New-Object PSObject
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Display Name" -Value $Group.DisplayName
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Email Address" -Value $PrimaryAdd
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Received" -Value $MessageReceivedList.Count
$GroupStatusObject | Add-Member -membertype NoteProperty -Name "Send" -Value $MessageSendList.Count
$GroupMessageStatus += $GroupStatusObject
}
Examples
Example 1: Generate a detailed report of a group named 'group1' from 2014/03/10 to 2014/03/14 in Exchange Online
The sample is shown below
GetGroupUtilization.ps1 –EXOService –identity group1 –StartDate 03/10/2014 –EndDate 03/14/2014
Command Screenshot:
Result Screenshot:
Example 2: Generate a DG utilization report in Exchange Online tenant, and this report will be stored in D:\ExchangeReport and the file name will be DGStatics.csv
The sample is shown below
GetActiveSyncDeviceReport.ps1 -EXOService -Path 'D:\ExchangeReport' -FileName DGStatics.csv
Command Screenshot:
Result Screenshot:
Prerequisites
Exchange Online
Exchange 2010
Exchange 2013
Windows PowerShell 2.0Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused
Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script
samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.