Exchange 2018 get mailbox size all databases

To get the mailbox size for all databases in Exchange 2018, you can use the following PowerShell command:

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object -ExpandProperty TotalItemSize

This command will retrieve a list of all mailboxes in the Exchange organization, and then use the Get-MailboxStatistics cmdlet to retrieve the total size of each mailbox. The Select-Object cmdlet is used to expand the TotalItemSize property, which contains the total size of each mailbox.

If you want to get the mailbox size for all databases in a specific Exchange server, you can use the following command:

Get-MailboxDatabase -Server <ServerName> | Get-MailboxStatistics | Select-Object -ExpandProperty TotalItemSize

Replace <ServerName> with the name of the Exchange server you want to retrieve the mailbox size for.

If you want to get the mailbox size for all databases in the entire Exchange organization, you can use the following command:

Get-MailboxDatabase | Get-MailboxStatistics | Select-Object -ExpandProperty TotalItemSize

This command will retrieve the mailbox size for all databases in the entire Exchange organization.

Note: The Get-MailboxStatistics cmdlet returns the total size of each mailbox in bytes. If you want to display the size in a more human-readable format, you can use the Format-Table cmdlet to format the output:

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object -ExpandProperty TotalItemSize | Format-Table -Property TotalItemSize -FormatString "{0:0.##} MB"

This command will display the total size of each mailbox in megabytes (MB).