Get mailbox’s age for Exchange 2010

Introduction

This script can list mailbox’s age for Exchange 2010.

Scenarios

IT Administrators may care about the mailbox’s age.  This script can list mailbox’s age for Exchange 2010.

Script

This script has only 1 parameter as follows:

Identity: The Identity parameter specifies the identity of the mailbox. You can use one of the following values:

* GUID

* Distinguished name (DN)

* Domain\Account

* User principal name (UPN)

* LegacyExchangeDN

* SmtpAddress

* Alias 

How to run script manually:

  1. Open Exchange Management Shell in “Run as Administrator” mode.
  2. Switch to the path, where you download the script.
  3. Run the script as example command below.  

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

PowerShell
Edit|Remove
param ($CreatedTime) 
$TimeSpan="" 
$tempTimeSpan=[int](New-TimeSpan -Start $CreatedTime -End $Today).TotalDays 
if ($tempTimeSpan -ge 365{  
    $TimeSpan+=[string]([int]($tempTimeSpan/365)) + " years," 
    $tempTimeSpan=$tempTimeSpan%365}if ($tempTimeSpan -ge 30{  
    $TimeSpan+=[string]([int]($tempTimeSpan/30)) + " months," 
    $tempTimeSpan=$tempTimeSpan%30} 
$TimeSpan+=[string]$tempTimeSpan+" days" 
$TimeSpan

Examples 

Example 1: How to get age of all mailboxes,

To get mailboxes’ age, run the following command:

.\OSCMailboxAge.ps1

Example 2: How to get age of specified mailboxes

To get mailboxes’ age, run the following command:

.\OSCMailboxAge.ps1 -Identity "david"

Example 3: How to export result to a CSV file.

To export result to a CSV file, run the following command:

.\ OSCMailboxAge.ps1|export-csv d:\result.csv -NoTypeInformation

Additional Resources

Technical Resources:

Get-Mailbox

http://technet.microsoft.com/en-us/library/bb123685(v=exchg.141).aspx

Export-CSV

http://technet.microsoft.com/en-us/library/hh849932