How Can We Help?
Powershell – Export Mailbox Size, Quota, and Storage Limit Status Report to CSV
The below PowerShell script first gets all user mailboxes and retrieves mailbox statistics for all mailboxes one by one. Finally, exports the mailbox name, primary and alias smtp email addresses, current mailbox usage size (TotalItemSize), storage warning quota (IssueWarningQuota), maximum size limit (ProhibitSendQuota), and size limit status (StorageLimitStatus) to a CSV file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
$Result =@() #Get all user mailboxes $mailboxes = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox #Get all shared mailboxes #$mailboxes = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails SharedMailbox $totalmbx = $mailboxes .Count $i = 0 $mailboxes | ForEach-Object { $mbx = $_ #Get mailbox statistics $mbs = Get-MailboxStatistics -Identity $mbx .Identity $i ++ Write-Progress -activity "Processing $mbx" -status "$i out of $totalmbx completed" if ( $mbs .TotalItemSize -ne $null ){ $size = [math] ::Round(( $mbs .TotalItemSize.ToString().Split( '(' )[1].Split( ' ' )[0].Replace( ',' , '' )/1MB),2) } else { $size = 0 } $Result += New-Object -TypeName PSObject -Property $( [ordered] @{ Name = $mbx .DisplayName PrimarySmtpAddress = $mbx .PrimarySmtpAddress AliasSmtpAddresses = ( $mbx .EmailAddresses | Where-Object { $_ -clike 'smtp:*' } | ForEach-Object { $_ -replace 'smtp:' , '' }) -join ';' TotalSizeInMB = $size SizeWarningQuota= $mbx .IssueWarningQuota StorageSizeLimit = $mbx .ProhibitSendQuota StorageLimitStatus = $mbs .ProhibitSendQuota }) } $Result | Export-CSV "C:\Temp\MailboxSizeReport.csv" -NoTypeInformation -Encoding UTF8 |