PowerShell: list mailbox database statistics (quota, mailbox count and size) - version 2 - Identity Management | Tools4ever
PowerShell: list mailbox database statistics (quota, mailbox count and size) – version 2

PowerShell: list mailbox database statistics (quota, mailbox count and size) – version 2

Door: Arnout van der Vorst

This script now includes reading the quota settings per mailbox database. There is no need to specify the input, as it automatically iterates through all mailbox databases in the organization (as long as your user account has sufficient permissions to see them). Then it starts building up a table object and filling rows with the results. This works pretty well, since you can use the table for sorting, displaying and usage in other scripts.

After you execute the below script, you will get a $table object containing all the data. To filter and sort this, use for example:

$table | where-object {$_.MailboxCount -gt 1} | sort “MailboxCount” | ft -autosize

The above statements filters and keeps all rows where the MailboxCount column is greather than 1, then sorts on that column and formats the table as output.

Another example is:

$table | where-object {$_.IssueWarningQuotaMB -gt 300 -and $_.IssueWarningQuotaMB -lt 1000} | sort “MailboxCount” | ft -autosize

The script to generate $table:

$table = New-Object system.Data.DataTable “$myTable”
$col1 = New-Object system.Data.DataColumn Identity,([string])
$col2 = New-Object system.Data.DataColumn MailboxCount,([decimal])
$col3 = New-Object system.Data.DataColumn SizeMB,([decimal])
$col4 = New-Object system.Data.DataColumn ProhibitSendQuotaMB,([decimal])
$col5 = New-Object system.Data.DataColumn ProhibitSendReceiveQuotaMB,([decimal])
$col6 = New-Object system.Data.DataColumn IssueWarningQuotaMB,([decimal])
$table.columns.add($col1)
$table.columns.add($col2)
$table.columns.add($col3)
$table.columns.add($col4)
$table.columns.add($col5)
$table.columns.add($col6)
$dbs = Get-MailboxDatabase
foreach ($db in $dbs)
{
$dbstats = Get-MailboxStatistics -database $db
$totaldbsize = 0
$totalmbcount = 0
foreach ($dbstat in $dbstats)
{
$totalmbcount = $totalmbcount + 1
$totaldbsize = $totaldbsize + $dbstat.TotalItemSize.Value.ToMB()
}
$row = $table.NewRow()
$row.Identity = $db.Identity
$row.MailboxCount = $totalmbcount
$row.SizeMB = $totaldbsize
$row.ProhibitSendQuotaMB = $db.ProhibitSendQuota.Value.ToMB()
$row.ProhibitSendReceiveQuotaMB = $db.ProhibitSendReceiveQuota.Value.ToMB()
$row.IssueWarningQuotaMB = $db.IssueWarningQuota.Value.ToMB()
$table.Rows.Add($row)
}
$table | sort “identity” | ft -AutoSize

Arnout van der Vorst

Geschreven door:
Arnout van der Vorst

Maak kennis met Arnout van der Vorst, de inspirerende Identity Management Architect bij Tools4ever sinds het jaar 2000. Na zijn studie Hogere Informatica aan de Hogeschool van Utrecht is hij begonnen als Supportmedewerker bij Tools4ever. Daarna heeft Arnout zich opgewerkt tot een sleutelfiguur in het bedrijf.  Zijn bijdragen strekken zich uit van klantondersteuning tot strategische pre-sales activiteiten, en hij deelt zijn kennis via webinars en artikelen.

Anderen bekeken ook

De vooroordelen van Single Sign On

De vooroordelen van Single Sign On

29 november 2011

SAP koppeling met Active Directory

SAP koppeling met Active Directory

06 september 2012

RBAC: sleutelrol, beheer en evolutie

RBAC: sleutelrol, beheer en evolutie

15 maart 2011

User- en toegangsbeheer in cloud applicaties: een uitdaging

User- en toegangsbeheer in cloud applicaties: een uitdaging

04 september 2012