From c23b803dc602e70ec1f5fb95bdf1e801675402f6 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Wed, 15 Apr 2026 17:53:15 -0400 Subject: [PATCH] sync_intune: align Phase 3/5/6 columns; ignore benign 'Failed: 0' tails Cosmetic + accuracy fixes spotted on the live test PC: - Phase 3 deploy/install lines had a stray double-space after the checkbox; Phase 5 'Share creds present in HKLM' and Phase 6 'Administrator renamed' had wider misalignment. All four lines collapsed to single-space-after-checkbox so the column lines up with the rest of the table. - Phase 4 status detector was greping the last 30 lines of each Install-*.log for /(?i)\b(ERROR|Failed|exception)\b/. That hit benign summary lines like 'Failed: 0' or 'Errors: 0' and marked successful runs as failed (Install-VCRedists.ps1 was the trigger -- 8/8 'Already installed - skipping' but the summary contained 'Failed: 0' and Phase 4 said FAILED). Tightened the regex to also exclude /\b(ERROR|Failed|Failures|Errors|Exceptions?)\s*[:=]\s*0\b/ so the keyword has to be next to a non-zero value (or the vocabulary 'Exit code 1603 - FAILED' style still trips correctly). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Shopfloor/lib/Monitor-IntuneProgress.ps1 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 index 4326a4a..f32d1a9 100644 --- a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 +++ b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 @@ -239,7 +239,14 @@ function Get-CustomScriptStatuses { $tail = Get-Content $_.FullName -Tail 30 -ErrorAction SilentlyContinue $hasError = $false if ($tail) { - $errMatch = $tail | Where-Object { $_ -match '(?i)\b(ERROR|Failed|exception)\b' } | Select-Object -First 1 + # Filter out benign matches that come from summary/total lines like + # " Failed: 0" or "Errors: 0" or "Exceptions=0" -- the keyword + # is there but with a zero/empty value. Look for real failures: + # the keyword followed by content that is NOT just zero. + $errMatch = $tail | Where-Object { + $_ -match '(?i)\b(ERROR|Failed|exception)\b' -and + $_ -notmatch '(?i)\b(ERROR|Failed|Failures|Errors|Exceptions?)\s*[:=]\s*0\b' + } | Select-Object -First 1 if ($errMatch) { $hasError = $true } } $status = if ($age -lt 30) { 'running' } @@ -544,8 +551,8 @@ function Format-Snapshot { } $lines += "" $lines += " Phase 3: DSC deployment + install" - $lines += " $(Mk $Snap.Phase3.DeployLogExists) DSCDeployment.log present" - $lines += " $(Mk $Snap.Phase3.DeployComplete) Pre-reboot deployment complete" + $lines += " $(Mk $Snap.Phase3.DeployLogExists) DSCDeployment.log present" + $lines += " $(Mk $Snap.Phase3.DeployComplete) Pre-reboot deployment complete" $lines += " $(Mk $Snap.Phase3.InstallLogExists) DSCInstall.log present" $lines += " $(Mk $Snap.Phase3.InstallComplete) Post-reboot install complete" $lines += "" @@ -575,11 +582,11 @@ function Format-Snapshot { $lines += "" $lines += " Phase 5: SFLD credentials" $lines += " $(Mk $Snap.Phase5.ConsumeCredsTask) Consume Credentials task scheduled" - $lines += " $(Mk $Snap.Phase5.CredsPopulated) Share creds present in HKLM" + $lines += " $(Mk $Snap.Phase5.CredsPopulated) Share creds present in HKLM" $lines += "" $lines += " Phase 6: Lockdown" $lines += " $(Mk $Snap.Phase6.AutologonShopfloor) Winlogon autologon = ShopFloor" - $lines += " $(Mk $Snap.Phase6.AdminRenamed) Administrator renamed -> SFLDAdmin" + $lines += " $(Mk $Snap.Phase6.AdminRenamed) Administrator renamed -> SFLDAdmin" } else { $lines += "" $lines += " (DSC phases not applicable for $pcType)"