View Mailboxes in Exchange Server 2007 who Exceed Quota Limit


Mailbox quotas help control the size of mailboxes, For example, would you like to know which mailboxes have reached their prohibit send receive quota, Or view the mailbox size and quota status of a specific mailbox?

You can do all that with the Get-Mailbox and Get-MailboxStatistics Exchange PowerShell cmdlets.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | where {$_.StorageLimitStatus -notlike "BelowLimit*"} | select DisplayName,LegacyDN,DatabaseName,StorageLimitStatus|Export-Csv c:\ExceedQuota.csv

The above script will loop through each Mailboxes and will get each Mailbox Statistics where their StorageLimitStatus not BelowLimit.

The Get-MailboxStatistics has a property where you can fetch each a property with Where statement and braces bracket {} to get the StorageLimitStatus Property.

The result of the above script is the below table;

DisplayName LegacyDN DatabaseName StorageLimitStatus
Full Display Name /O=Organization/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=Alias Students-DB10 ProhibitSend

Manual work has to be done to remove the LegacyDN and keep only the Alias CTRL+H find what and Replace All is a good to delete the entire LegacyDN name and keep only the Alias.

You can use another script to move the mailbox from one Database which has got a quota limited quota to a higher Database which has higher quota.

In order to move the Mailbox to higher quota Database, you need to know the Database Storage Limit Size. You can achieve this by running the Get-MailboxDatabase cmdlet in Exchange PowerShell and pipe it with the property of ProhibitSendReceiveQuota
 Get-MailboxDatabase | select Name, StorageGroup, ProhibitSendReceiveQuta | Export-CSV C:\DBQuota.csv

Name StorageGroup ProhibitSendReceiveQuota
Staff-DB1-H MAILSERVER\Staff-SG 2355MB
Staff-DB2-N MAILSERVER\Staff-SG 1111520KB
Staff-DB3-L MAILSERVER\Staff-SG 515520KB
Students-DB1 MAILSERVER\Students-SG 1000MB
Students-DB2 MAILSERVER\Students-SG 100MB
Students-DB3 MAILSERVER\Students-SG 200MB
Students-DB4 MAILSERVER\Students-SG 311999KB
Students-DB5 MAILSERVER\Students-SG 1300000KB
Students-DB6 MAILSERVER\Students-SG2 400MB
Students-DB7 MAILSERVER\Students-SG2 522000KB
Students-DB8 MAILSERVER\Students-SG2 800MB
Students-DB9 MAILSERVER\Students-SG2 919200KB
Students-DB10 MAILSERVER\Students-SG2 1024160KB
Staff-DB4-O MAILSERVER\Staff-SG 5000MB
Students-DB11 MAILSERVER\Students-SG3 200MB
Students-DB12 MAILSERVER\Students-SG3 200MB
Students-DB13 MAILSERVER\Students-SG3 200MB
Students-DB14 MAILSERVER\Students-SG3 200MB

Now it’s time to move the Mailboxes from their current Database where has got limited quota to the higher Databases which has higher quota.

In order to move the require users from one Database to another, you need to put their Alias/EmailID into a text file to be called by another script and start moving the mailbox to the target Database.

You can filter the first CSV export by Database Column to get all the users in the limited quota database, copy only the  Alias/EmailID to a text file and use the below script to move them to the target Database;


#############################
# Move-Multiple-Mailbox.ps1 #
# Created By Assaf Miron #
# Date : 06/11/07 #
#############################

Param(
[String]$TargetDB,
[String]$FileToOpen,
[Boolean]$ValidateOnly=$False
)

function IsHelpRequest
{
param($argument)
return ($argument -eq "-?" -or $argument -eq "-help");
}

# Function that displays the help related to this script following
# the same format provided by get-help or -?
Function Usage
{
@"

NAME:
`tMove-Multiple-Mailbox.ps1 [-FileToOpen][-TargetDB]

SYNOPSIS:
`tMoves a list of mailboxes listed in an Excel File to
`ta specific Database.

SYNTAX:
`tMove-Multiple-Mailbox.ps1
`t`t[ -FileToOpen ]
`t`t[ -TargetDB ]
`t`t[ -ValidateOnly [True/False] ]

PARAMETERS:
`t-FileToOpen (required)
`t`tAn Text File wich Contains Principle Names of Users to Move
`t-TagretDB (required)
`t`tTarget Databse Name
`t-ValidateOnly (optional)
`t`tDoesn't move the mailboxes but checks if they can move to the target DB

`t-------------------------- EXAMPLE 1 --------------------------

C:\PS> .\Move-Multiple-Mailbox.ps1 -FileToOpen "C:\UsersToMove.txt" -TargetDB "Students-DB6"

`t-------------------------- EXAMPLE 2 --------------------------

C:\PS> .\Move-Multiple-Mailbox.ps1 -FileToOpen "C:\UsersToMove.txt" -TargetDB "Students-DB6" -ValidateOnly $true

REMARKS:
`tThe Move Mailbox accours with the Max threads Parameter
`tit will not move mailboxes that have errors
`tor mailboxes that need to preserve thier size.

"@
}

####################################################################################################
# Script starts here
####################################################################################################

# Check for Usage Statement Request
$args | foreach { if (IsHelpRequest $_) { Usage; exit; } }

$arrMailboxes = @()

# Validate the parameters
If ($TargetDB -eq "") { Usage; exit; }
Else {
If ($FileToOpen -eq "") { Usage; exit; }
Else {
write-host $FileToOpen

$arrMailboxes = Get-Content $FileToOpen

Write-Host "About to move"$arrMailboxes.Count"Mailboxes to"$TargetDB
$Ans = Read-Host "is This information Correct ? `n[Yes,No]`nDefault(Yes)"
If ($Ans.Contains("n")) { exit; }
If ($ValidateOnly -eq $True)
{
$arrMailboxes | Move-Mailbox -TargetDatabase $TargetDB -MaxThreads 16 -ValidateOnly
}
Else
{
$arrMailboxes | Move-Mailbox -TargetDatabase $TargetDB -MaxThreads 16
}
}
}

Advertisements

, , , , , , , ,

  1. Leave a comment

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: