Skip to Content

PowerShell-Check-Mailbox

We are beginning to transition to Windows 7 across the Enterprise, which is nice and change is often a time to revisit some basic tools and short comings.

Our support center currently fields basic calls from users on mailbox issues. Currently they are using the Exchange 2007 Admin tools which after about 6 clicks gets them most of the information they need, usually. It does miss mailbox size limits as generally that is set on a store level and on the account screen says merely 'default' and we have different sizes depending on job function.

We also run into the occasional issue of multiple accounts found based on our naming policy those then have to be filtered out based on looking closer at account infomration. I hacked together this quick function to provide basic information with one command and no need for the GUI.

Here's the output

PS:\> Check-MailBox jdoe
 
        Display Name:  John Doe
      Mailbox Server:  mailserver01
 
       Issue Warning:  219 MB
       Prohibit Send:  244 MB
Storage Limit Status:  BelowLimit
 
Current Mailbox Size:  220 MB

and here is the basic function...

# Check-Mailbox -Steven Peck
function Check-MailBox {
<#
.SYNOPSIS
 
Gets basic mailbox stats for a given user using the users logonID.
Requires Quest AD Cmdlet Get-QADuser and Microsoft Exchange shell extentions.
 
.EXAMPLE
 
Check-Mailbox ca99999
 
#>
 
# Mandatory Input parameters, throw an error if null or blank
  Param ( 
    [parameter(Mandatory = $true, ValueFromPipeline=$true)] 
    [ValidateNotNullOrEmpty()] 
    [String]
    $LogonID
  ) 
 
  $UserName = Get-QADUser $LogonID 
 
  # Get-MailBox $UserName.DisplayName | Format-Table DisplayName, ServerName, {$_.ProhibitSendQuota.Value.ToMB()}, {$_.ProhibitSendReceiveQuota.Value.ToMB()}, {$_.IssueWarningQuota.Value.ToMB()} 
  # Get-MailboxStatistics $UserName.DisplayName | Format-Table displayName, storagelimitstatus, {$_.TotalItemSize.Value.ToMB()} -autosize
 
  $mb = Get-MailBox $UserName.DisplayName 
  $mbs = Get-MailboxStatistics $UserName.DisplayName
 
  Write-Host " "
  Write-host "        Display Name: " $UserName.DisplayName
  Write-Host "      Mailbox Server: " $mb.ServerName
  Write-Host " "
  Write-Host "       Issue Warning: " $mb.IssueWarningQuota.Value.ToMB() "MB"
  Write-Host "       Prohibit Send: " $mb.ProhibitSendQuota.Value.ToMB() "MB"
  Write-Host "Storage Limit Status: " $mbs.storagelimitstatus
  Write-Host " "
  Write-Host "Current Mailbox Size: " $mbs.TotalItemSize.Value.ToMB() "MB"
  Write-Host " "
 
}

We'll see if they adopt this approach over time. So far some early adopters seem to like it but it is unknown if they will change teir existing habbits to use it. If they don't then no more scripts for them.

Commenting on this Blog entry is closed.