This script can list mailbox’s age for Exchange 2010.
IT Administrators may care about the mailbox’s age. This script can list mailbox’s age for Exchange 2010.
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:
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.
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
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
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
Technical Resources:
Get-Mailbox
http://technet.microsoft.com/en-us/library/bb123685(v=exchg.141).aspx
Export-CSV