Exchange Powershell snippets

For reference some PowerShell snippets for Exchange Management Shell usage.

Mailbox related

Get mailbox size of one mailbox:

Get-MailboxStatistics [username] | ft DisplayName, TotalItemSize, ItemCount  

Get mailbox size of all mailboxes (no system mailboxes):

Get-Mailbox | Get-MailboxStatistics  | where {$_.ObjectClass –eq “Mailbox”} | ft DisplayName, TotalItemSize, ItemCount

Export one complete mailbox to .PST file:
User has to be member of the ‘Mailbox Import Export’ role, without this role the New-MailboxExportRequest function is not available (reload PowerShell session after adding current user to role).

New-ManagementRoleAssignment -Role "Mailbox Import Export" -User "<user name or alias>"
New-MailboxExportRequest -Mailbox <user> -FilePath [path-to-shared-folder]\....pst