Skip to content

Fix Register-CWAAHealthCheckTask drift detection and failure-path logging - #11

Merged
christaylorcodes merged 4 commits into
developfrom
fix/register-healthcheck-task-drift-detection
Jul 27, 2026
Merged

Fix Register-CWAAHealthCheckTask drift detection and failure-path logging#11
christaylorcodes merged 4 commits into
developfrom
fix/register-healthcheck-task-drift-detection

Conversation

@christaylorcodes

Copy link
Copy Markdown
Owner

Summary

  • Widens drift detection to compare the full repair command and interval (Server/LocationID/InstallerToken/IntervalHours), not just the installer token, so config changes correctly trigger task recreation.
  • Adds a post-create verification step (task can be reported as created by schtasks and then removed immediately by AV/policy) that now actually gates success reporting: on verification failure, the function logs event 4023, skips the 4020 success log, and returns Created=$false instead of falsely reporting success.
  • Verification uses an schtasks /QUERY check instead of Get-ScheduledTask, keeping the function on PowerShell 2.0/3.0-compatible tooling (the ScheduledTasks module requires PS 3.0+/Windows 8+) and consistent with the existing schtasks-based existence check.
  • Ensures Write-CWAAEventLog still logs the 4022 failure event even when the caller has $ErrorActionPreference = 'Stop'.
  • Adds/updates Pester coverage for drift on interval and Server/LocationID, the verification-failure path (asserting the corrected Created=$false result and that 4020 is not also logged), and the creation-failure path.
  • Minor: documents event IDs 4022/4023 in Write-CWAAEventLog's event ID reference.

Test plan

  • ./Scripts/Invoke-QuickTest.ps1 -IncludeAnalyzer -OutputFormat Structured → success, 0 failed, 0 analyzer errors
  • ./Tests/test-local.ps1 → build, analyze, and test stages all pass (483 passed, 0 failed, 8 skipped)

🤖 Generated with Claude Code

christaylorcodes and others added 4 commits June 18, 2026 09:30
…ging

Broadens the existing-task comparison to cover InstallerToken, Server,
LocationID, and IntervalHours together instead of just the token, so
config changes actually recreate the task. Adds post-create verification
via Get-ScheduledTask (the incident this fixes is a task getting removed
immediately after creation) and fixes Write-CWAAEventLog never firing on
the failure path when the caller has $ErrorActionPreference = 'Stop'.

+semver: patch
…ledTasks dependency

The new post-create verification step logged a 4023 error event when the task
was missing, but still fell through into the success path (4020 log, Created=$true).
Verification failure now gates the success reporting so callers get an accurate
Created/Updated result.

Also replaces Get-ScheduledTask with an schtasks-based check for the same
verification, since ScheduledTasks module requires PS 3.0+/Win8+ and the rest of
this function intentionally shells out to schtasks.exe for broader compatibility.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CI resolves build dependencies fresh on every run with no lockfile/cache, and
Sampler was pinned to 'latest'. A newer Sampler release (0.120.0) changed the
built-module output path resolution, breaking the Create_changelog_release_output
task ("Could not find the built module manifest"). Pin to the version already
verified locally via ./Tests/test-local.ps1.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@christaylorcodes
christaylorcodes merged commit b155cf3 into develop Jul 27, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant