Archive

Posts Tagged ‘Exchange 2007;Exchange 2010;PowerShell’

Exchange 2010 Archive Mailbox Statistics PowerShell script

September 29th, 2011 7 comments


Here are some field notes from a recent Exchange 2010 Retention and Archive case.

I have made a simple Exchange 2010 PowerShell script Get-ArchivedMBStats.ps1, that shows mailbox statistics for all mailboxes that have Online Archive enabled. It is great for following the progress of archiving of individual mailboxes.

The output of the script is the following information about each mailbox with archive enabled:

  • Mailbox Display Name
  • Mailbox TotalItemSize (MB)
  • Mailbox ItemCount
  • Mailbox Database
  • Mailbox RetentionPolicy
  • Archive Display Name
  • Archive TotalItemSize (MB)
  • Archive ItemCount
  • Archive Database
      The output is show as:

    Display Name    TotalItemSize (MB)   ItemCount    Database      RetentionPolicy
    ————    —————–    ———    ——–      —————
    Peter Schmidt                 147         3572      EXDB01    Default Archive..
    Online Archive – Pet…       430         4798      ARDB01

Here is the code (download as zip at the end of the article):

###########################################################################
#
# NAME: Get-ArchivedMBStats.ps1
#
# AUTHOR: Peter Schmidt
# EMAIL: peter@msdigest.net
#
# COMMENT: Shows all mailboxes that are enabled for Online Archvie in Exchange 2010. Output shows both Mailbox and Archived Mailbox statistics.
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 2011.09.29 - Initial release
#
# OUTPUT EXAMPLE:
#	Display Name                 TotalItemSize (MB)               ItemCount Database                RetentionPolicy
#	------------                 ------------------               --------- --------                ---------------
#	Peter Schmidt                               147                    3572 EXDB01                  Default Archive and ...
#	Online Archive - Pet...                     430                    4798 ARDB01
#
# HOW TO RUN:
#	.Get-ArchivedMBStats.ps1 | ft
#
# INPUTS:
#	None. You cannot pipe objects to this script.
#
###########################################################################

$combCollection = @()

Write-Host "`nPlease wait...`n"

$archiveMailboxes = Get-Mailbox | where {$_.ArchiveDatabase -ne $null} | Select Identity, RetentionPolicy

ForEach ($mbx in $archiveMailboxes)
{
	$mbxStats = Get-MailboxStatistics $mbx.Identity | Select DisplayName, TotalItemSize, ItemCount, Database
	$archiveStats = Get-MailboxStatistics $mbx.Identity -Archive | Select DisplayName, TotalItemSize, ItemCount, Database

	$mbcomb = "" | Select "Display Name", "TotalItemSize (MB)", ItemCount, Database, RetentionPolicy
	$archcomb = "" | Select "Display Name", "TotalItemSize (MB)", ItemCount, Database

	$mbcomb."Display Name" = $mbxStats.DisplayName
	$mbcomb."TotalItemSize (MB)" = [math]::round($mbxStats.TotalItemSize.Value.ToMB(), 2)
	$mbcomb.ItemCount = $mbxStats.ItemCount
	$mbcomb.Database = $mbxStats.Database
	$mbcomb.RetentionPolicy = $mbx.RetentionPolicy
	$archcomb."Display Name" = $archiveStats.DisplayName
	$archcomb."TotalItemSize (MB)" = [math]::round($archiveStats.TotalItemSize.Value.ToMB(), 2)
	$archcomb.ItemCount = $archiveStats.ItemCount
	$archcomb.Database = $archiveStats.Database

	$combCollection += $mbcomb
	$combCollection += $archcomb
	$combCollection += "`n"
}
write-output $combCollection
Write-Host "`nList of archived mailboxes done...`n" -Foregroundcolor Green

Download script here:

Get-ArchiveMBStats (52.0 KiB, 435 downloads)

Redirect to TechNet Gallery.

Using Exchange MessageTracking with wildcards

September 17th, 2011 No comments


Here are some field notes from a recent message tracking case.

If you have to find all messages from one certain domain, that have entered your Exchange environment, this is possible using Exchange Management Shell and the Get-MessageTrackingLog cmdlet.

Run the following:

Get-MessageTrackingLog -Server "ExchangeServerName" -Start "8/1/2011" -End "9/1/2011" -resultsize unlimited | where {$_.Sender -like *@domain.com}

This works on Exchange 2007 and 2010.