Windows PowerShell is deployed by Microsoft. PowerShell is a Framework for the automation of task and its configuration. The tasks are performed in commandlets and it consists of command-line shell as well as scripting language.
The PowerShell provides many features such as; manipulation of objects, command-based navigation, extensible interface, gets mailbox size, contains design, cmdlets for performing system administration, etc.
PowerShell Developers:
The developers are;
They allow the developers to have their own PowerShell modules, functions, etc.
Now, PowerShell has become a big hand for the Exchange Server. The Get-MailboxReport.ps1 script of PowerShell enables to generate reports of the server mailbox statistics. Let us see how the size of mailbox of the Exchange server is seen in PowerShell. In PowerShell, we will be able to see the information according to our needs or wishes.
The Get-MailboxStatistics cmdlet gets the user the details of the mailbox on the server such as; size of mails, mail counts, last accessed time, etc.
Syntax is:
Get- MailboxStatistics {username}
The user can get the details according to the requirement; you need to mention it properly. To get the name, size and total count the following syntax is to be followed.
Syntax:
Get-MailboxStatistics {username} |ft DisplayName, TotalItemSize, ItemCount
If we want, we can view the report in text file using the syntax as following;
Filtering:
For filtering out only the items specified to the ‘mailbox’, user needs to follow up;
Get -MailboxStatistics | where {$_.ObjectClass_eq “Mailbox”
To Sort Out:
Always an ordered view gives a good look. There are commands for the reordering of the item lists seen. There are two ways to clear the busted items; descending and ascending.
Let’s see how descending works.
Syntax:
Get – MailboxStatistics| Sort –Object TotalItemSize – Descending
Same syntax is also used for ascending, just need to change Descending to Ascending.
Change Size format:
We can convert the size to MB if necessary and for that need to do a replacing of ‘TotalItemSize’ to
After customizing the view is;
There are many other options of customizing. The syntaxes are;
Customize using:
ItemCount;
StorageLimitStatus;
DisplayName;
All these above mentioned commands can be grouped together and we can obtain the result; helps in saving the time. The one line is:
Get-MailboxStatistics | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto
There are many ways by which the PowerShell helps the users of Exchange Server. Using the PowerShell, the sum, minimum, average, etc. of the ‘TotalItemSize’ can be calculated as well. However, not all those details are mentioned here in the article but, an overall view of the usage of PowerShell is mentioned and hope will be helpful.