Exchange Server 2010/2013 Health Check PowerShell Script (v5.4)

A re-work of my previous ExDac utility for Exchange Server 2010 which was written in .NET

Now, this is written in PowerShell instead of VB.net, and as a result, the entire script runs for half the time than the previous tool.

What the script does?

The script performs several checks on your Exchange Servers like the ones below:
  • Server Health (Up Time, Server Roles Services, Mail flow,...)
  • Mailbox Database Status (Mounted, Backup, Size, and Space, Mailbox Count, Paths,...)
  • Public Folder Database Status (Mount, Backup, Size, and Space,...)
  • Database Copy Status
  • Database Replication Status
  • Mail Queue
  • Disk Space
  • Server Components (for Exchange 2013/2016)
Then an HTML report will be generated and can be sent via email if enabled in the configuration file.

I have not tested this for Exchange 2016 but in theory, this should work just as well (let me know if it doesn't).

Sample Output










Parameters

  • -configFile, to specify the XML file that contain the configuration for the script.
  • -enableDebug, optional switch to start a transcript output to debugLog.txt

Configuration File

The configuration file is an XML file containing the options, thresholds, mail settings, exclusion that will be used by the script. The snapshot of the configuration file is seen below:


reportOptions

This section can be toggled by changing values with "true" or "false"

  • RunServerHealthReport - Run test and report the Server Health status
  • RunMdbReport - Mailbox Database test and report
  • RunComponentReport - Server Components check (Exchange 2013/2016)
  • RunPdbReport - For checking the Public Folder database(s)
  • RunDAGReplicationReport - Check and test replication status
  • RunQueueReport - Inspect mail queue count
  • RunDiskReport - Disk space report for each server
  • RunDBCopyReport - Checking the status of the Database Copies
  • SendReportViaEmail - Option to send the HTML report via email
  • ReportFile - File path and name of the HTML Report

thresholds


This section defines at which levels the script will report a problem for each check item

  • LastFullBackup - age of full backup in days. Setting this to zero (0) will cause the script to ignore this threshold
  • LastIncrementalBackup - age of incremental backup in days. Setting this to zero (0) will cause the script to ignore this threshold.
  • DiskSpaceFree - percent (%) of free disk space left
  • MailQueueCount - Mail transport queue threshold
  • CopyQueueLenght - CopyQueueLenght threshold for the DAG replication
  • ReplayQueueLenght - ReplayQueueLenght threshold
  • cpuUsage – CPU usage threshold %
  • ramUsage – Memory usage threshold %


mailAndReportParameters

This section specifies the mail parameters
  • CompanyName - the name of the organization or company that you want to appear in the banner of the report
  • MailSubject - Subject of the email report
  • MailServer - The SMTP Relay server
  • MailSender - Mail sender address
  • MailTo - Recipient address. For multiple recipients, separate the addresses with a semi-colon (;)

exclusions

This section is where the exclusion can be defined.
  • IgnoreServer - List of servers to be ignored by the script. Separate with a comma (,) with no spaces.
  • IgnoreDatabase - List of Mailbox Database to be ignored by the script. Separate with a comma (,) with no spaces.
  • IgnorePFDatabase - List of Public Folder Database to be ignored by the script. Separate with a comma (,) with no spaces.

How to Use

Run manually using Exchange Management Shell




[PS] C:\scripts>.\Get-ExchangeHealth.ps1 -configFile .\config.xml -enableDebug

Note: This must be run within the Exchange Management Shell session. Avoid using this inside the normal PowerShell session, with the Exchange 2010 PSSnapin loaded especially for Exchange 2013 servers.

Task Scheduler

Create a task in Task Scheduler with this action:

Program/script: powershell.exe
Add arguments: -Command ".'C:\Program Files\Microsoft\Exchange Server\V15\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; C:\scripts\Get-ExchangeHealth.ps1 -configFile C:\scripts\Get-\config.xml"

Download

You can find the latest script and config.xml file in this GitHub repository:

Change Logs

Version 5.4 (Latest)

  • Added CPU and Memory Utilization Checks
    • New configuration in config.xml (ramUsage, cpuUsage, RunCPUandMemoryReport)
  • Code clean-up

Version 5.3 (skipped, crappy version)

Version 5.2 (Latest)

  • Several code cleanups
  • Renamed RunDAGCopyReport to RunDBCopyReport (because it makes more sense to call it that)
  • Removed Add-PSSnapin code because it didn't play well with Exchange 2013. Hence the need to use Exchange Management Shell.
  • Added the Version and Edition of Exchange Server column in Server Health report
  • Revised the Get-MailQueues function
  • Added AdminDisplayVersion identification in Get-ServerHealth function
  • Removed PowerShell-Remoting code from the Mail flow test
  • Renamed Get-DAGCopyStatus function to Get-DatabaseCopyStatus
  • Added CopyQueueLenght threshold in XMLconfig file
  • Added ReplayQueueLenght threshold in XMLconfig file
  • Added Server Components check (for Exchange 2013)
  • Added RunComponentReport option in XML config file
  • Added section in XML config file
  • Added IgnoreServer,IgnoreDatabase,IgnorePFDatabase fields in XML config file
  • Added counter for the number of tests, passed and failed.
  • Added percentage computation for overall health
  • The "Issues" table is not visible from the report if there are no actual issues detected
  • Added individual test results summary
  • Added logic to not run DAG checks if there are no DAGs
  • Added logic to not run Mail Flow test against Mailbox Servers with no Active Mailbox Database

Version 5.1

  • Added new parameter "configFile" where you will need to specify the configuration XML file which contains the variables that used to be included inside the script in previous versions.
  • Moved the Variables to an outside XML file (default is config.xml) You can create different XML files with different configurations/variables if desired.
  • To run: "Get-ExchangeHealth.ps1 -configFile config.XML"
  • Added DAG Copy Status
  • Fixed the Math for getting back up age

Version 4.4b

  • Corrected version information within the script
  • Added BCC and CC line within the @params variable block, but are commented out.
  • Added comments to:
  • [int]$t_lastincrementalbackup
  • [int]$t_lastfullbackup
  • Added comments to:
  • $MailCC
  • $MailBCC

Version 4.4

  • Added Test-MailFlow Handle for Exchange 2013
  • Moved Test-MailFlow Result to Server Health Status Report
  • Exclude Edge Servers from Testing
  • Public Folder Database Report will not run if database count is 0

Version 4.3

  • Renamed script to Get-ExchangeHealth.ps1
  • Added Test-MapiConnectivity
  • Added Test-MailFlow
  • Added Services Status
  • Added DNS/Ping Test
  • Added Server Up Time
  • Changed Backup Threshold from Days to Hours

Version 4.0

  • Added DAG Members Replication Checks
  • Added Mail Queue Checks
  • Added DB Activation Preference Check
  • Added "Summary" Section
  • Fixed HTML character recognition issues

Older versions --- :)

Share:

1 comment:

  1. Hi,

    is it possible to exclude exchange 2010 servers from report.

    ReplyDelete

Popular Posts

Powered by Blogger.