Set permissions to run powershell scripts
Set-ExecutionPolicy RemoteSigned
The Get-MailboxStatistics command is used to display mailbox size. The instace displayed below shows the details for a single mailbox and displays the listed information for the mailbox in addition.
View mailbox Size: Get-MailboxStatistics -identity username | ft DisplayName, TotalItemSize, ItemCount, StorageLimitStatus, Database
This expounds on the previous command. If you place the following commands into a .PS1 script and run from inside powershell it will prompt you for the user name, display the size then ask if you would like to check another. A very simple example of how you can use scripts with these commands.
One User Script:
DO {
$name = read-host "Enter username"
Get-MailboxStatistics -identity $name | ft DisplayName, TotalItemSize, ItemCount, StorageLimitStatus, Database
$ask = read-host "Check Another? (Y|N)"
}
WHILE ($ask -eq "Y")
This command steps up from displaying a single mailbox to displaying every mailbox on the given server and sorts by mailbox size. This is followed by an example listing only the mailboxes for a given database. In addition you can limit the output to the first X number of results with the select-output command shown last.
All Users
Get-MailboxStatistics -server "mailserver1" | Sort-Object TotalItemSize -Descending | ft DisplayName, TotalItemSize, ItemCount, StorageLimitStatus, Database
Admin Database:
Get-MailboxStatistics -Database "Admin" | Sort-Object TotalItemSize -Descending | ft DisplayName, TotalItemSize, ItemCount, StorageLimitStatus, Database
Top 10 mailboxes in the Admin Database my size:
Get-MailboxStatistics -Database "Admin" | Sort-Object TotalItemSize -Descending | ft DisplayName, TotalItemSize, ItemCount, StorageLimitStatus, Database | Select-Object –first 10
No comments:
Post a Comment