We are Office365.

We need to Generate a report in CSV that will give us

Display Name

MailBox Size (which i believe is TotalItemSize)

Mailbox Quota

I want this to be displayed in descending order based on TotalItemSize

Appreciate your advise and help

4 Spice ups

This is the basic PowerShell I use -

Get-Mailbox -ResultSize Unlimited |

Get-MailboxStatistics |

Select DisplayName, `

@{name=“TotalItemSize (MB)”; expression={[math]::Round( `

($_.TotalItemSize.ToString().Split(“(”)[1].Split(" “)[0].Replace(”,“,”")/1MB),2)}}, `

ItemCount |

Sort “TotalItemSize (MB)” -Descending

1 Spice up

Inkmaster has your back and is on point here.

Report back if you need more

1 Spice up

Run this, it works in my environment.

get-mailbox -server “server” -ResultSize unlimited |Where {$.UseDatabaseQuotaDefaults -eq $false} |Select-Object DisplayName,IssueWarningQuota,ProhibitSendQuota,@{label=“TotalItemSize(MB)”;expression={(get-mailboxstatistics $).TotalItemSize.Value.ToMB()}}| Export-Csv “C:\test\UserMailboxSizes.csv” -NoTypeInformation

Here is a similar issue for reference. https://social.technet.microsoft.com/Forums/Windows/en-US/454351f8-bc30-4631-ac0c-077d913fb598/powershell-script-to-generate-quota-mailbox-size-report?forum=exchangesvradminlegacy

@Inkmaster - I like to have the below columns in my report for each user

ProhibitSendQuota

ProhibitSendReceiveQuota

IssueWarningQuota

How do I add these into the below:

Get-Mailbox -ResultSize Unlimited |

Get-MailboxStatistics |

Select DisplayName, `

@{name=“TotalItemSize (MB)”; expression={[math]::Round( `

($_.TotalItemSize.ToString().Split(“(”)[1].Split(" “)[0].Replace(”,“,”")/1MB),2)}}, `

ItemCount |

Sort “TotalItemSize (MB)” -Descending

Get-Mailbox -ResultSize Unlimited |

Get-MailboxStatistics |

Select DisplayName,ProhibitSendQuota,ProhibitSendReceiveQuota,IssueWarningQuota, `

@{name="TotalItemSize (MB)"; expression={[math]::Round( `

($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}, `

ItemCount |

Sort "TotalItemSize (MB)" -Descending

Try that and report back

1 Spice up
I get the below error

At C:\Reports\MailBoxStats04.ps1:9 char:84
+ ... ,"")/1MB),2)}}, `
+                    ~
Missing expression after ','.
At C:\Reports\MailBoxStats04.ps1:11 char:1
+ ItemCount |
+ ~~~~~~~~~
Unexpected token 'ItemCount' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingExpressionAfterToken

Forgot the comma after IssueWarningQuota,

I corrected my post try it again…

1 Spice up

Hi Gregory,

I get the report but some of the fields are blank. please see screenshot below

1 Spice up

hmm that is odd

This is Exchange online right?

1 Spice up

Yes exchange online

Try this through the web admin portal and report back findings

1 Spice up
foreach($users in Get-Mailbox -ResultSize Unlimited){$users | Foreach-Object {

$user = $_

$stats = Get-MailboxStatistics $user.userprincipalname

$a=get-user $user.userprincipalname

New-Object -TypeName PSObject -Property @{

DisplayName = $User.DisplayName

IssueWarningQuota = $User.IssueWarningQuota

ProhibitSendQuota = $User.ProhibitSendQuota

ProhibitSendReceiveQuota = $user.ProhibitSendReceiveQuota

TotalItemSize = $stats.TotalItemSize

}

}

}

I am able to get the output with the above. However,

  1. I need the TotalItemSize to show in MB

  2. Have TotalItemSize in Descending order

Appreciate if you can assist me on how to change the code

Add

@{name=“TotalItemSize (MB)” ;

| Sort “TotalItemSize (MB)” -Descending

at the appropriate position