I needed a simple one-liner to list all huge email folders. I came up this one - simple, clear and self-documenting:
[PS]> get-mailbox | Get-MailboxFolderStatistics | where {$_.foldersize -gt 5Gb} | sort -desc foldersize | select identity, foldersize | ft -auto
Identity
FolderSize
--------
----------
domain.local/MyBusiness/Users/Dave\Inbox 6.155 GB (6,608,825,034 bytes)
domain.local/MyBusiness/Users/John\Sent Items 5.112 GB (5,489,056,989 bytes)
What I want is this:
DisplayName Name FolderSize
----------- ---- ----------
Dave Inbox 6.155 GB
John Sent Items 5.112 GB
or this, which is just trimming the Identity and FolderSize fields I already have:
Identity FolderSize
-------- ----------
Dave\Inbox 6.155 GB
John\Sent Items 5.112 GB
In the first example, I need the DisplayName field, and If I'm on the folder level, DisplayName is blank; how can I pull it from the mailbox level? (In other words, a Format-List at the mailbox level shows the user name is Name; and at the folder level, the folder name is Name.)
In the second example, can I manipulate the output and have it still be a simple one-liner?
Any experts out there who can shed some light will be greatly appreciated. I really can use the report as-is, but it would be much cleaner with the repeating information removed.
Rob