[CmdletBinding()] param( [string]$HealthScriptPath = (Join-Path $PSScriptRoot 'Test-DomovoyProductionHealth.ps1'), [string]$NotificationScriptPath = (Join-Path $PSScriptRoot 'Send-DomovoyHealthNotification.ps1') ) $ErrorActionPreference = 'Stop' Set-StrictMode -Version Latest if (-not (Test-Path -LiteralPath $HealthScriptPath -PathType Leaf)) { throw 'Health monitoring script not found' } if (-not (Test-Path -LiteralPath $NotificationScriptPath -PathType Leaf)) { throw 'Health notification script not found' } $pwsh = (Get-Command pwsh.exe -ErrorAction Stop).Source & $pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $HealthScriptPath $healthExitCode = $LASTEXITCODE & $pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $NotificationScriptPath $notificationExitCode = $LASTEXITCODE if ($notificationExitCode -ne 0) { exit 2 } exit $healthExitCode