If your playing around with different Mailbox quota values you might want to see what the usage of those quotas would be before you apply them to a Mailbox. This is a very simple Mailbox Size script for Remote Powershell to show you this with a funky console graph output (and a CSV report) eg
So what the script does is the normal Get-Mailbox | Get-MailboxStatistics to get the TotalSize of the Mailbox in MB and compares that against a QuotaIf Value you feed into script in the above example that was 2000 MB. It then works out the current percentage used and the produces an Alt-ASCII graph and the above table.
When you run this script you need to feed in the QuotaIf value eg
.\quotaIf.ps1 2000
I've put a download of this script here and code itself looks like
So what the script does is the normal Get-Mailbox | Get-MailboxStatistics to get the TotalSize of the Mailbox in MB and compares that against a QuotaIf Value you feed into script in the above example that was 2000 MB. It then works out the current percentage used and the produces an Alt-ASCII graph and the above table.
When you run this script you need to feed in the QuotaIf value eg
.\quotaIf.ps1 2000
I've put a download of this script here and code itself looks like
- $QuotaIfVal = $args[0]
- $Script:rptCollection = @()
- get-mailbox -ResultSize unlimited| Get-MailboxStatistics | foreach-object{
- $rptObj = "" | Select MailboxName,TotalSize,QuotaIfPercent,PercentGraph
- $rptObj.MailboxName = $_.DisplayName
- [Int64]$rptObj.TotalSize = ($_.TotalItemSize.ToString() |%{($_.Substring($_.indexof("(")+1,$_.indexof("b")-$_.indexof("(")-2)) -replace(",","")})/1MB
- $rptObj.QuotaIfPercent = 0
- if($rptObj.TotalSize -gt 0){
- $rptObj.QuotaIfPercent = [Math]::round((($rptObj.TotalSize/$QuotaIfVal) * 100))
- }
- $PercentGraph = ""
- for($intval=0;$intval -lt 100;$intval+=4){
- if($rptObj.QuotaIfPercent -gt $intval){
- $PercentGraph += "▓"
- }
- else{
- $PercentGraph += "░"
- }
- }
- $rptObj.PercentGraph = $PercentGraph
- $rptObj | fl
- $Script:rptCollection +=$rptObj
- }
- $Script:rptCollection
- $Script:rptCollection | Export-Csv -NoTypeInformation -Path c:\temp\QuotaIfReport.csv -Encoding UTF8