Count number of folders in mailbox (Exchange or O365)

Despite there being a limitation on the number of folders an Exchange on-premises/O365 based mailbox will allegedly allow, there is no simple way to identify how may folders and subfolders a user has in their mailbox. The Microsoft solution? Count them manually…

However the following PowerShell script will provide you with a folder count (note this will include the system folders) for the specified user, or you can simply omit the -Identity “UserName@domain.com” part to list the count for all users (but this may take a while!):

$Mailboxes = Get-Mailbox -Identity “UserName@domain.com”

$Results = foreach( $Mailbox in $Mailboxes )
{
$Folders = $MailBox |
Get-MailboxFolderStatistics |
Measure-Object |
Select-Object -ExpandProperty Count
New-Object -TypeName PSCustomObject -Property @{
Username = $Mailbox.Alias
FolderCount = $Folders
}
}
$Results | Select-Object -Property Username, FolderCount | Sort FolderCount -Descending

Related Posts

Need IT Help?

If you need assistance please feel free to reach out to us.