add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$layout = ""
$time = get-date | ConvertTo-HTML -Head $layout -as LIST DateTime -Body "
Report Execution Time
"
$mailcount = Get-Mailbox | Group-Object database | Sort Name | convertto-html -Head $layout Name, Count -Body "Exchange Database Mailbox Count
"
$maildbsize = Get-MailboxDatabase -status |ConvertTo-HTML -Head $layout Name,Databasesize -Body "Exchange Database Size
"
$activedb = Get-MailboxServer | Get-MailboxDatabaseCopyStatus -Active |Convertto-html -Head $layout name,contentindexstate -Body "Active Database Server
"
$emailinfo = @{
Subject = "Exchange Stats Report from $env:ComputerName.$env:USERDNSDOMAIN - $((Get-Date).ToShortDateString())"
Body = $time, $mailcount, $maildbsize, $activedb |
Out-String
From = "ExDBStats@pipe2text.com"
To = "BC@pipe2text.com"
SmtpServer = "smtp.pipe2text.com"
}
Send-MailMessage @emailinfo -BodyAsHtml