pshealthz
pshealthz copied to clipboard
Basic HTTP listener written in PowerShell that executes Operation Validation Framework (OVF) tests and returns results using a simple REST API
PSHealthZ
Overview
Basic HTTP(S) listener that executes Operation Validation Framework (OVF) tests that are present on the given system and returns results using a simple REST API. This is an implementation of the Health Endpoint Monitoring Pattern using PowerShell.
Getting Started
Start the listener on the desired port and path. The command below will expose a REST endpoint at http://localhost:1938/health.
This command must be run from an elevated session.
>$listener = Start-HealthzListener -PassThru -Verbose
This will create a PowerShell job running the listener in the backgound. To see the listener details, run:
$listener | Format-List *
To test the listener, run the following:
>$r = Invoke-RestMethod -Uri 'http://localhost:1938/health'
>$r | Format-List *
Without specifying a specific test to execute, PSHealthZ will return a list of available OVF tests that are present in $env:PSModulePath.
>$r.availableTests
Storage Capacity Memory Capacity OVF.Example1
Services asdf OVF.Example2
More services OVF.Example2
Logical Disks OVF.Windows.Server
Memory OVF.Windows.Server
Network Adapters OVF.Windows.Server
Operating System OVF.Windows.Server
To execute a specific test, add '?test=<testname>' as a query parameter.
>$r = Invoke-RestMethod -Uri 'http://localhost:1938/health?test=services'
To execute tests from a specific module, add '?module=<modulename>' as a query parameter.
>$r = Invoke-RestMethod -Uri 'http://localhost:1938/health?module=ovf.example1'
You can inspect the test results with:
>$r.testResults | Format-Table *
To stop the HTTP listener, run:
$listener | Stop-HealthzListener