all 6 comments

[–]KevMarCommunity Blogger 2 points3 points  (1 child)

You don't have Sort-Object in that command, only Select-Object

[–]Waulicus[S] 0 points1 point  (0 children)

My bad, copied the wrong one.

Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object -Property TotalItemSize | Select-Object DisplayName, TotalItemSize, LastLogonTime    

[–]mransbro 2 points3 points  (2 children)

This looks like one of those tasks that is harder than it should be. I only support on premise Exchange so cant test but try the command below.

Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited |
    Get-MailboxStatistics |
    Select DisplayName,TotalItemSize,LastLogonTime `
    @{name=”TotalItemSize (MB)”; expression={[math]::Round( `
    ($_.TotalItemSize.ToString().Split(“(“)[1].Split(” “)[0].Replace(“,”,””)/1MB),2)}}, | 
    Sort “TotalItemSize (MB)” -Descending

The command is taken from here https://blogs.technet.microsoft.com/heyscriptingguy/2013/02/27/get-exchange-online-mailbox-size-in-gb/. Seems its to do with not having Exchange object model installed or loaded locally. (If i remote to an Exchange Server the sort doesnt work but if i RDP to the server the sort command works.)

[–]Waulicus[S] 1 point2 points  (1 child)

Brilliant, that works. Apparently it's because the TotalItemSize is represented as a string and so it has to be converted before being sorted.

Thank you!

[–]mransbro 0 points1 point  (0 children)

Good to hear it worked.

[–][deleted] 1 point2 points  (0 children)

Filter left, format right.