This script will connect to Exchange Online, and export mailbox size information to CSV format. The mailbox sizes are reported in MB, and the report is sorted from the highest mailbox size to the smallest.<\/p>\n
Open PowerShell (or PowerShell ISE, whatever is your preference), and connect to Exchange Online:<\/p>\n
$cred = Get-Credential In the script below, change the path in the bottom line to meet your needs:<\/p>\n get-mailbox -ResultSize Unlimited |
\n$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/<\/a> -Credential $cred -Authentication Basic -AllowRedirection
\nImport-PSSession $Session<\/p>\n<\/div>\n<\/a>Step 2: Convert mailbox sizes to MB and export to CSV<\/h3>\n
<\/a>Sorts mailboxes by size and exports to CSV<\/h1>\n
\nGet-MailboxStatistics |
\nselect displayname,@{n=“Total Size (MB)”;e={[math]::Round( `
\n($_.totalitemsize.ToString().Split(“(”)[1].Split(\" “)[0].Replace(”,“,”\")/1MB),1)}} |
\nsort “Total Size (MB)” -Descending |
\nexport-csv “C:\\Users\\Username\\Desktop\\MailboxSizeReport.csv” -NoTypeInformation<\/p>\n<\/div>","step":[{"@type":"HowToStep","name":"Connect to Exchange Online","text":"\nOpen PowerShell (or PowerShell ISE, whatever is your preference), and connect to Exchange Online:\n\n# Connects O365 session\n$cred = Get-Credential\n$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection\nImport-PSSession $Session"},{"@type":"HowToStep","name":"Convert mailbox sizes to MB and export to CSV","text":"\nIn the script below, change the path in the bottom line to meet your needs:\n\n# Sorts mailboxes by size and exports to CSV\nget-mailbox -ResultSize Unlimited |\nGet-MailboxStatistics |\nselect displayname,@{n=\"Total Size (MB)\";e={[math]::Round( `\n($_.totalitemsize.ToString().Split(\"(\")[1].Split(\" \")[0].Replace(\",\",\"\")/1MB),1)}} |\nsort \"Total Size (MB)\" -Descending |\nexport-csv \"C:\\Users\\Username\\Desktop\\MailboxSizeReport.csv\" -NoTypeInformation"}]}