sus42

A Blog on Wndows Server and Microsoft Exchange by Thomas Pätzold

Advanced Mailboxstatistics

leave a comment »


As an administrator of a large Exchange System you have configured a mailboxquota for each mailbox. But the interesting question is what is the ratio between the configured quota and the used mailboxstore. In order to get this value you have to create your own Windows Powershell function.

The following function enumerates all data and stores it in a custom object. So you are able to work with this object.

function get-mailboxquotausage {
<#
.SYNOPSIS
	This function enumerates the configured quota and used mailboxstore for each mailaddress
	of a maildomain. The user is able to specify the maildomain as a parameter to this function.
.DESCRIPTION
	This script enumerates all mailaddresses from one primary maildomain. Displayname, primary SMTP address, prohibit send quota and the used mailboxstore are displayed.
.PARAMETER Maildomain
	This parameter specifies the maildomain this function will work on.
.EXAMPLE
	get-mailboxquotausage -maildomain aixtest.de
	
	Description
	===========
	This command will show the displayname, primary SMTP address, prohibit send quota and used mailboxstore for the domaine @aixtest.de
	
.EXAMPLE
	get-mailboxquotausage -maildomain aixtest.de | select displayname, @{label="size (MB)"; expression={"{0,0:N0}" -f $_.size}}, @{label="quota (MB)"; expression={"{0,0:N0}" -f $_.quota}}
	

	Description
	============
	This command will show the displayname, primary SMTP address, prohibit send quota and used mailboxstore for the domaine @aixtest.de.
	The displayed values will be displayed with a decimal point according to the configured language setting.
#>




[CmdletBinding()]
param([Parameter(Mandatory=$True, ValueFromPipeline=$True)][string]$maildomain)

begin {
}


process{
$delete = 0
$result = @()
$users=get-mailbox |? {$_.primarysmtpaddress -like "*$maildomain*"}

foreach ($user in $users) {

	$userstats=Get-MailboxStatistics $user 

	$obj=new-object psobject
	$obj = @{}
	$obj.add("Displayname", $user.displayname)
	$obj.add("Mailaddress", $user.primarysmtpaddress)
	write-host $user.primarysmtpaddress
	if (-not $user.prohibitsendquota.isunlimited) {
		$obj.add("Quota", ($user.prohibitsendquota.value.toMB()))
	} else {
		$obj.add("Quota", "unlimited")
	}
	$obj.add("Size", ($userstats.totalitemsize.value.toMB()))
	$result += new-object -type PSObject -Property $obj
}
$result
}

end{}

}
Advertisements

Written by Thomas Pätzold

January 28, 2013 at 9:40 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: