To get a list of all mailboxes and their sizes, the following command produces this information.
Get-Mailbox | Get-MailboxStatistics | select-object DisplayName,TotalItemSize
However the data outputted by this command is not in a format which can be used with script, it is not numeric as shown in the following screenshot.
To get the data for TotalItemSize just as a number such as KB, MB, GB etc, use the following commands:
{$_.TotalItemSize.Value.ToKB()}
{$_.TotalItemSize.Value.ToMB()}
{$_.TotalItemSize.Value.ToGB()}
For example:
Get-Mailbox | Get-MailboxStatistics | select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}
This will ensure the data returned is in a format which you can use for scripting.
Get-Mailbox | Get-MailboxStatistics | select-object DisplayName,TotalItemSize
However the data outputted by this command is not in a format which can be used with script, it is not numeric as shown in the following screenshot.
To get the data for TotalItemSize just as a number such as KB, MB, GB etc, use the following commands:
{$_.TotalItemSize.Value.ToKB()}
{$_.TotalItemSize.Value.ToMB()}
{$_.TotalItemSize.Value.ToGB()}
For example:
Get-Mailbox | Get-MailboxStatistics | select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}
This will ensure the data returned is in a format which you can use for scripting.