How to Fix PowerShell Parser Errors in Exchange Server Health Script
Question details
The user needs to fix parser errors encountered when running the Test-ExchangeServerHealth.ps1 script.
- Product
- Exchange Server
- Device & OS
- not provided
- Scenario
- Running a third-party health check script on Exchange Server 2016 CU22.
- Observed behavior
- The script throws errors related to unusual characters, HTML entities, missing string terminators, unexpected tokens, and missing closing braces.
Ensure you have downloaded the script as a raw .ps1 file rather than copying text directly from a web page, as web formatting is the most common cause of HTML entity and syntax errors.
Download and Execute a Clean Copy of the Script
Since Test-ExchangeServerHealth.ps1 is not a built-in script, downloading a fresh, uncorrupted copy directly resolves parser and syntax errors.
Errors involving missing braces and unexpected tokens typically indicate that the script file was damaged during download or improperly copied.
Download the Test-ExchangeServerHealth.ps1 script directly from its official repository, ensuring you download the raw file format.
Extract the downloaded file locally and move it to a known directory on your Exchange Server.
Launch the Exchange Management Shell (EMS) on your server with administrator privileges.
Navigate to the folder where you placed the script and run it by typing .\Test-ExchangeServerHealth.ps1 -ReportMode and pressing Enter.

Document Your IT Infrastructure with WPS Office
While WPS Office cannot execute PowerShell scripts, it is the perfect free alternative to Microsoft Office for writing server documentation and analyzing exported CSV health reports. It is lightweight, free, and completely compatible with Microsoft formats.
- 1. Download WPS Office: Visit the official WPS website to download the free installer.
- 2. Install the Software: Run the downloaded executable and follow the quick on-screen instructions.
- 3. Open and Edit Reports: Launch WPS Office to easily manage your server's exported CSV and PDF health reports.

Frequently Asked Questions
Why does my PowerShell script show HTML entity errors?
This usually happens if the script was copied and pasted from a web browser instead of being downloaded as a raw file, causing hidden HTML tags and formatted characters to be saved inside the .ps1 file.
Is Test-ExchangeServerHealth.ps1 a Microsoft built-in tool?
No, Test-ExchangeServerHealth.ps1 is a third-party, community-created script used by Exchange administrators. It is not natively included with Exchange Server installations.
How do I generate a health report after fixing the script?
Once the fresh script is correctly placed on your server, open the Exchange Management Shell, navigate to the script's directory, and run the command with the -ReportMode switch to generate the summary.




