Get-EXOMailboxFolderStatistics
Exchange Online Management: Gets folder statistics for a specified mailbox
#Requires -Version 5.1
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$Identity,
[ValidateSet('All','Archive','Calendar','Clutter','Contacts','ConversationHistory','DeletedItems','Drafts','Inbox','Journal','JunkEmail','LegacyArchiveJournals','ManagedCustomFolder','NonIpmRoot','Notes','Outbox','Personal','RecoverableItems','RssSubscriptions','SentItems','SyncIssues','Tasks')]
[string]$Folderscope = 'All',
[switch]$Archive,
[switch]$IncludeOldestAndNewestItems,
[switch]$IncludeSoftDeletedRecipients,
[ValidateSet('*','Name','LastModifiedTime','ItemsInFolder','DeletedItemsInFolder','FolderAndSubfolderSize','FolderSize','FolderType','FolderPath','Identity')]
[string[]]$Properties = @('Name','LastModifiedTime','ItemsInFolder','DeletedItemsInFolder','FolderAndSubfolderSize','FolderType','FolderPath')
)
Process {
try {
if ($Properties -contains '*') {
$Properties = @('*')
}
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'; 'Identity' = $Identity; 'Folderscope' = $Folderscope; 'Archive' = $Archive; 'IncludeOldestAndNewestItems' = $IncludeOldestAndNewestItems; 'IncludeSoftDeletedRecipients' = $IncludeSoftDeletedRecipients}
$result = Get-EXOMailboxFolderStatistics @cmdArgs | Select-Object $Properties
if ($null -eq $result -or $result.Count -eq 0) {
Write-Output "No folder statistics found"
return
}
foreach ($item in $result) {
$item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force
}
}
catch { throw }
}Name, Alias or SamAccountName of the mailbox
Scope of the search by folder type
Off
Return usage statistics of the archive mailbox associated with the mailbox
Off
Return dates of the oldest and newest items in each folder
Off
Include soft-deleted mailboxes in the results
List of properties to expand. Use * for all properties