harness: PS2 guard for onboarding probe + Windows quote-stripping memory

onboarding-diagnostic.ps1: add a PowerShell-version guard. The probe is PS3+ by
design (Get-CimInstance, [ordered], ConvertTo-Json); on stock PS2 (Win7 SP1 /
2008 R2 without WMF) it crashed with cryptic [ordered] errors and emitted empty
DIAG-JSON (first hit: AMT-PC). Now on PS<3 it emits a legible, parseable result
inside the DIAG-JSON markers (hand-built JSON) with a WMF 5.1 / KB3191566
remediation hint instead. Parses clean. True PS2-native probe stays an RMM Thought.

memory: add feedback_windows_quote_stripping (+ index) consolidating the two
recent embedded-double-quote incidents (PowerShell->curl.exe CommandLineToArgvW,
RMM->cmd.exe shutdown /c) into one root cause + fix, so future ref= entries land.

errorlog: the two self-logged entries from #32333 (preview-skip friction,
AMT-PC/Scileppi conflation correction).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-16 18:07:27 -07:00
parent 08fcafa0a4
commit 54c7f9940d
4 changed files with 86 additions and 0 deletions

View File

@@ -33,6 +33,35 @@ $ErrorActionPreference = 'Continue'
$ProgressPreference = 'SilentlyContinue'
Set-StrictMode -Off
# ---------------------------------------------------------------------------
# Legacy-PowerShell guard.
# This probe targets Windows PowerShell 5.1 (see .SYNOPSIS): it uses [ordered],
# Get-CimInstance, and ConvertTo-Json - ALL PowerShell 3.0+. On stock PowerShell
# 2.0 (Win7 SP1 / Server 2008 R2 without WMF) those throw and the probe emits
# empty DIAG-JSON with no grade. Rather than crash cryptically, emit a legible,
# parseable result (hand-built JSON - ConvertTo-Json is itself PS3+) so the
# runner still extracts a clean object plus a remediation hint. A true
# PS2-native probe is tracked separately in RMM_THOUGHTS (PS2-compat diagnostic).
# ---------------------------------------------------------------------------
if ($PSVersionTable.PSVersion.Major -lt 3) {
$legacyHost = $env:COMPUTERNAME
$legacyVer = $PSVersionTable.PSVersion.ToString()
$nowUtc = (Get-Date).ToUniversalTime()
$legacyUtc = $nowUtc.ToString('yyyy-MM-dd') + 'T' + $nowUtc.ToString('HH:mm:ss') + 'Z'
$detail = 'This host runs Windows PowerShell ' + $legacyVer + '. The onboarding probe requires PowerShell 3.0+ (it uses Get-CimInstance, [ordered], and ConvertTo-Json), so the full diagnostic could not run. Install WMF 5.1 (KB3191566) to enable it, or run the legacy-native probe when available.'
# Hand-built JSON - keep ASCII, no ConvertTo-Json on PS2.
$legacyJson = '{"host":"' + $legacyHost + '","collected_at_utc":"' + $legacyUtc + '",' +
'"os":{"powershell_version":"' + $legacyVer + '"},"facts":{},"findings":[' +
'{"id":"probe.legacy_powershell","category":"probe","severity":"unknown",' +
'"title":"Diagnostic probe requires PowerShell 3.0+",' +
'"detail":"' + $detail + '",' +
'"evidence":"PSVersion ' + $legacyVer + ' is older than 3.0"}]}'
Write-Output '===DIAG-JSON-START==='
Write-Output $legacyJson
Write-Output '===DIAG-JSON-END==='
exit 0
}
# ---------------------------------------------------------------------------
# Collectors
# ---------------------------------------------------------------------------