Here is something simple I was asked to help with. Powershell script for mailbox sizes and number of items.
So we start with:
Get-MailboxStatistics | ft displayname, TotalItemSize, itemcount
ft is short for format table. Wow but that is messy and totalitemsize is in bytes and dividing by 1024 in your head gives you KB and a headache. There is a function to get that into MB
Get-MailboxStatistics | ft displayname, @{ expression={$_.TotalItemSize.Value.ToMB() }, itemcount
But now the column heading is too big, so let's change the label.
Get-MailboxStatistics | ft displayname, @{ expression={$_.TotalItemSize.Value.ToMB() } ;label=”Mailbox (MB)” }, itemcount
Simple really. But you really want to see the big mailboxes at the top so it needs sorting into descending order of mailbox size instead of randomly given.
Get-MailboxStatistics | sort-object –property totalitemsize –desc | ft displayname, @{ expression={$_.TotalItemSize.Value.ToMB() } ;label=”TotalItemSize (MB)” }, itemcount
And next we may want to do all of our Exchange servers rather than just current server...
get-mailbox |
needs to go in front of the previous statement.
Summary: No, powershell is *not* the easiest of things to master but in some odd way it does actually make some sense. To an Exchange Engineer at any rate.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment