Home > Exchange 2007, Exchange 2010, Scripting > List Exchange 2010 Mailbox and AD Information and Send via Email

List Exchange 2010 Mailbox and AD Information and Send via Email

This is one of the more handy scripts I have put together.  It enumerates both the Active Directory and Exchange mailbox data\statistics and sends them to an administrator’s email account, in a nicely formatted message.

It lists:

Active Directory Information

  • Display Name
  • Simple Display Name
  • UserPrincipleName
  • Identity
  • Distinguished Name
  • GUID
    Exchange Mailbox Info

  • Display Name
  • Primary Email address
  • Exchange Server
  • Exchange Database
  • Recipient Type
  • Exchange Version
  • When Created
  • Client Throttling Policy
  • RoleAssignedPolicy
  • GAL Hidden status

Exchange Mailbox Statistics

  • Item Count
  • Size
  • Last Logon Time
  • Quota status

Safe Senders List

  • Status
  • Trusted Senders
  • Blocked Senders

Exchange Logon Statistics

  • Protocol
  • Client Name
  • Client Mode
  • Open Message Count
  • Open Folder Count

Exchange ActiveSync\Mobile Device Info

  • DeviceId
  • DeviceModel
  • First Sync Time
  • Last Sync Attempt
  • Last Ping time
  • Sync State
  • Number of Sync’d folders

The Output:

image

I am still working on the syntax for the Safe Senders list…..

The script:

#Author: Ed McKinzie edward@i-tekpro.com
#www.i-tekpro.com

#Load the Exchange snapin for 2010
$mailbox=Read-Host "Enter a mailbox you want to dump"
$mailbox_report=Read-Host "Enter a mailbox\Email Address you want to Send this report"
#Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Set-ADServerSettings -ViewEntireForest:$True
$FormatEnumerationLimit =-1

$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "BODY{font-size: 9pt; font-family: arial;font-color:#041F92}"
$a = $a + "TABLE{border-width: 0px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 0px;padding: 1px;border-style: solid;border-color: black;Font-color: white;background-color: Black; font-decoration: bold;}"
$a = $a + "TD{border-width: 0px;padding: 1px;border-style: solid;border-color: black;background-color: DarkKhaki}"
$a = $a + "</style>"

$b = "<H2><b><u>Active Directory Information</u></b></H2>"
$c = "<H2><b><u>Exchange 2010 Mailbox Info</u></b></H2>"
$d = "<H2><b><u>Mailbox Statistics</u></b></H2>"
$e = "<H2><b><u>Mailbox Mobile Device Info</u></b></H2>"
$f = "<H2><b><u>Mailbox Safe and Blocked Sender List</u></b></H2>"
$logonstatistics = "<H2><b><u>Exchange 2010 Mailbox Logon Statistics</u></b></H2>"


$bodyb = get-mailbox -identity $mailbox | Select DisplayName,SimpleDisplayName,UserPrincipalName,Identity,DistinguishedName,Guid | ConvertTo-Html -Head $a -Body $b
$bodyc = get-mailbox -identity $mailbox | Select DisplayName,PrimarySmtpAddress,ServerName,Database,RecipientType,ExchangeVersion,WhenCreated,ThrottlingPolicy,RoleAssignmentPolicy,HiddenFromAddressListsEnabled | ConvertTo-Html -Head $a -Body $c
$bodyd = get-mailboxstatistics -identity $mailbox | Select LastLoggedOnUserAccount, ItemCount, TotalItemSize, DeletedItemCount, TotalDeletedItemSize, LastLogonTime, StorageLimitStatus | ConvertTo-Html -Head $a -Body $d
$bodye = Get-ActiveSyncDeviceStatistics -mailbox $mailbox | Select DeviceID, DeviceModel, FirstSyncTime,LastSyncAttemptTime,LastPingHeartbeat,SyncStateUpgradeTime,NumberOfFoldersSynced | ConvertTo-Html -Head $a -Body $e
$bodyf = Get-MailboxJunkEmailConfiguration -identity $mailbox | Select Enabled,TrustedSendersAndDomains,BlockedSendersAndDomains | ConvertTo-Html -Head $a -Body $f


$bodylogonstatistics = get-mailbox -identity $mailbox | Get-LogonStatistics | select UserName,ApplicationId,ClientName,ClientMode,LogonTime,CurrentOpenMessages,CurrentOpenFolders | ConvertTo-Html -Head $a -Body $logonstatistics

 

 

Send-MailMessage -To $mailbox_report -From "Administrator@vlab.com" `
-Subject "Exchange Mailbox Dump $mailbox" -SmtpServer "SMTPSERVER.DOMAIN.COM" -Body `
($bodyb, $bodyc, $bodyd, $bodyf, $bodylogonstatistics, $bodye | Out-String) -BodyAsHtml

Usage: Run the script and pass it two variables at the prompts:

  1. The alias of the mailbox you want to dump
  2. The Email address of the person you want to send the report

Best of luck,

Ed McKinzie

www.i-tekpro.com

Advertisements
  1. MrT
    October 10, 2012 at 3:01 PM

    how about adding a section for DL membership, and users which have full access to the mailbox.

  2. December 20, 2013 at 12:54 PM

    This works great, thanks for posting it.

  1. No trackbacks yet.

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: