RSS
email

Exchange summary reports

Taking a cue from a post on the Windows Powershell Blog, by James Brundage, I decided to create a few notifications for my Exchange environment.

These little “scriptlets” will pop off a notification message in HTML format with a summary of information gathered by each.

The information is not server specific, as I tried to limit the number of instances required. And the content is very basic, but it gets the job done.

You can refer to James’ post above for more information on how to automatically schedule these to run.

You can copy the scripts by hovering over the code block and selecting “view source”

Mailbox database summary:
#//Mailbox Database Reports
$messageParameters = @{
    Subject = "Exchange 2007 Database Report - $((Get-Date).ToShortDateString())"
    Body =  Get-MailboxDatabase -status | 
   Select-Object Server, Name, Mounted, LastFullBackup | 
   Sort-Object Server, Name |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
Exchange 2007 queue summary:
#//Exchange 2007 Queue Report
$messageParameters = @{
    Subject = "Exchange 2007 Queue Report - $((Get-Date).ToShortDateString())"
    Body =  Get-TransportServer |
   ForEach-Object { Get-Queue -Server $_ | 
   Select-Object NextHopDomain, MessageCount, Status} | 
   Sort-Object NextHopDomain |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
Exchange 2003 queue summary:
#//Exchange 2003 Queue Report
$messageParameters = @{
    Subject = "Exchange 2003 Queue Report - $((Get-Date).ToShortDateString())"
    Body =  Get-ExchangeServer | 
   Where-Object {$_.IsExchange2007OrLater -eq $False} |
   ForEach-Object {
   Get-WmiObject -class exchange_smtpqueue -namespace ROOT\MicrosoftExchangev2 -computername $_ | 
   Where-Object -FilterScript {$_.MessageCount -gt 0} |  
   Select-Object VirtualMachine, QueueName, MessageCount, Size} |
   Sort-Object VirtualMachine |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
Exchange 2007 MAPI connectivity summary:
#//MAPI Connectivity Report
$messageParameters = @{
    Subject = "MAPI Connectivity Report - $((Get-Date).ToShortDateString())"
    Body =  Get-MailboxServer |
   Where-Object {(get-mailboxdatabase -Server $_ ).count -gt '0'} |
   ForEach-Object { Test-MAPIConnectivity -Server $_ |
   Select-Object Server, Database, Result, @{Name="Latency(MS)";expression={(([TimeSpan] $_.Latency).TotalMilliSeconds)}}, Error} |
   Sort-Object Server, Database |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
Exchange server disk summary:
#//Disk Space Reports
$messageParameters = @{
    Subject = "Exchange Disk Space Report - $((Get-Date).ToShortDateString())"
    Body =  Get-ExchangeServer |
   ForEach-Object { Get-WmiObject -computer $_ Win32_LogicalDisk} | 
   Where-Object {$_.DriveType -eq 3} |
   Select-Object SystemName, DeviceID, VolumeName, @{Name="Size(GB)";expression={[math]::round(($_.Size / 1073741824))}}, @{Name="Free(GB)";expression={[math]::round(($_.FreeSpace / 1073741824))}}, @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Size / 1073741824)) * 100),0)}} | 
   Sort-Object SystemName, DeviceID |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
Exhcange services summary:
#//Exchange Services Report
$messageParameters = @{
    Subject = "Exchange Services Report - $((Get-Date).ToShortDateString())"
    Body =  Get-ExchangeServer | 
   ForEach-Object {
   Get-WmiObject -computername $_ -query "select * from win32_service where Name like 'MSExchange%' or Name like 'IIS%' or Name like 'SMTP%' or Name like 'POP%' or Name like 'W3SVC%'" | 
   Select-Object SystemName, DisplayName, StartMode, State} |
   Sort-Object SystemName, DisplayName |
         ConvertTo-Html |
         Out-String
    From = "exrept@domain.com"
    To = "you@domain.com"
    SmtpServer = "10.10.10.10"
}
Send-MailMessage @messageParameters -BodyAsHtml
Bookmark and Share

3 comments:

YB said...

Hi Jean,

I am trying to run the scriptlets but I keep getting an error:

Unrecognized token in source text.
At C:\script\queue.ps1:2 char:22
+ $messageParameters = @ <<<<

I've tryed adding an ' before and after the @ and other combinations but nothing works.

Any idea?

Jean Louw said...

Hello YB,

These scripts require Powershell V2 :)

Hope it helps!

Jean

YB said...

Ah gotcha. I missed that. Ok, I suppose I can't use this just yet :(

Thanks Jean

Post a Comment

Note: Only a member of this blog may post a comment.