October 12, 2017

Exchange Online - Get-MailboxStatisticsDetails

.SYNOPSIS
Gets detailed mailbox statistic information in Exchange Online

.DESCRIPTION
When you configure cache settings in outlook you need to choose how much data you want to store locally.
This script helps to identify the size of mailbox for specific time range: 3 days, 1 week, 2 weeks 1 month etc. up to 2 years.
It includes information about archive size and items count. The script accepts pipeline and the result can be exported to csv file.



.PARAMETER UserPrincipalName
UPN of queried mailbox. Mandatory parameter.

.PARAMETER MaxRange
Specifies maximum range for the query. Available options:
TotalOnly - shows only total mailbox statistics. Mailbox Size in MB.
3Days - Shows Total information including the statistics for the last 3 days.
1Week - Shows Total, 3 days and 1 week.
2Weeks - same as above including 2 weeks.
1Month, 3Months, 6Months, 1Year, 2Years - same logic as above.

.PARAMETER IncludeItemsCount
Not mandatory parameter. The output will include mailbox items count information.

.PARAMETER ExcludeArchiveItems
Not mandatory parameter. By specifying this parameter the output will not include archive items.

.EXAMPLE
The output will include information about mailbox name, UPN, when mailbox was created, status of archive (enabled or disabled), Total Mailbox Size in MB and Archive Size. 
.\Get-MailboxStatisticsDetails.ps1 -UserPrincipalName mailbox@example.com -MaxRange TotalOnly 

.EXAMPLE
The same as above including mailbox Total and Archive Items count.
.\Get-MailboxStatisticsDetails.ps1 -UserPrincipalName mailbox@example.com -MaxRange TotalOnly -IncludeItemsCount

.EXAMPLE
The same as above but Total Size and Total Items will not include archive items.
.\Get-MailboxStatisticsDetails.ps1 -UserPrincipalName mailbox@example.com -MaxRange TotalOnly -IncludeItemsCount -ExcludeArchiveItems

.EXAMPLE
Exactly the same result as previous example including statistics information for last 3 days, 1 week, 2 weeks, 1 month and 3 months.
.\Get-MailboxStatisticsDetails.ps1 -UserPrincipalName mailbox@example.com -MaxRange 3Months -IncludeItemsCount -ExcludeArchiveItems

.EXAMPLE 
Exports above example to csv file.
.\Get-MailboxStatisticsDetails.ps1 -UserPrincipalName mailbox@example.com -MaxRange 3Months -IncludeItemsCount -ExcludeArchiveItems | Export-Csv filename.csv

.EXAMPLE
Script accepts pipeline. Example below.
Get-Mailbox mailbox@example.com | .\Get-MailboxStatisticsDetails.ps1 -MaxRange TotalOnly

.EXAMPLE
Report for all users mailboxes, sorted by Name, include items count and exclude archive items, then export the result to csv file.
Get-Mailbox -RecipientTypeDetails UserMailbox | .\Get-MailboxStatisticsDetails.ps1 -MaxRange TotalOnly -IncludeItemsCount -ExcludeArchiveItems | Export-Csv filename.csv

.NOTES
You need to be connected to Exchange Online PowerShell prior running this script.
Account should have appropriate rights to run "Get-Mailbox", "Search-Mailbox" and "Get-MailboxStatistics" cmdlets.
The script may not work (not accurate results for log time queries) with "Microsoft Exchange Online PowerShell Module" (MFA case) due to session timeout.
It is assumed that queried mailboxes have less than 10K items weekly load (which is common for regular mailbox use). Otherwise the results can be inaccurate.

The script can be downloaded on TechNet Gallery - https://gallery.technet.microsoft.com/Exchange-Online-Get-b80dcabf

No comments:

Post a Comment