From a8d38f611741c51995016ba08fba19a4538b90ef Mon Sep 17 00:00:00 2001 From: cproudlock Date: Wed, 13 May 2026 15:41:52 -0400 Subject: [PATCH] imaging: load Send-PxeStatus at script scope + bump QR size to 160px Monitor-IntuneProgress.ps1: the previous Ensure-SendPxeStatus function ran '. $lib' from inside the function body. PowerShell's dot-source- inside-function semantics put the imported Send-PxeStatus into the function's LOCAL scope, not the script scope. By the time Get-Phase1 called Get-Command Send-PxeStatus, the function had already returned and Send-PxeStatus was out of scope - silently never invoked, no log entry at all (success or failure). Diagnostic confirmed: bay had DeviceId in dsregcmd, manual Send-PxeStatus from operator prompt fired idx=7 cleanly with QR rendered, but Monitor's automatic call never showed up in C:\Logs\send-pxe-status.log. Fix: dot-source at script top-level (outside any function). Then Send-PxeStatus is in script scope where every function in the file can call it. Keep Ensure-SendPxeStatus as a no-op stub for any caller still invoking it. imaging.html: bump QR data-qr-size from 56 to 160 px. A 36-char UUID at ECC M needs ~29x29 modules; at 56px each module was ~1.5px which is too tight for a phone camera to lock onto from typical distance. 160 px gives ~5 px/module which scans cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Shopfloor/lib/Monitor-IntuneProgress.ps1 | 20 ++++++++++--------- webapp/templates/imaging.html | 17 +++++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 index 8045c60..92d8ed4 100644 --- a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 +++ b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 @@ -188,16 +188,18 @@ $script:cache = @{ DeviceIdReported = $false } -# Lazy-load Send-PxeStatus so the dashboard can render a QR of the Intune -# device GUID as soon as it's captured. Dot-source path mirrors the helper -# usage in the 09-Setup-*.ps1 scripts. -$script:sendPxeStatusLoaded = $false +# Load Send-PxeStatus at SCRIPT scope (not inside a function). A dot-source +# inside a function defines the imported function in that function's local +# scope only, so callers from other functions can't see it and Get-Command +# Send-PxeStatus returns nothing. Loading at the top of the script puts +# Send-PxeStatus in script scope where every function can find it. +$pxeStatusLib = Join-Path $PSScriptRoot 'Send-PxeStatus.ps1' +if (Test-Path $pxeStatusLib) { + try { . $pxeStatusLib } catch { Write-Warning "Send-PxeStatus dot-source failed: $_" } +} function Ensure-SendPxeStatus { - if ($script:sendPxeStatusLoaded) { return } - $lib = Join-Path $PSScriptRoot 'Send-PxeStatus.ps1' - if (Test-Path $lib) { - try { . $lib; $script:sendPxeStatusLoaded = $true } catch { } - } + # Kept as a no-op shim for any callers that still invoke it. Real load + # happens at script init above. } function Get-Phase1 { diff --git a/webapp/templates/imaging.html b/webapp/templates/imaging.html index d3dd648..e7cac74 100644 --- a/webapp/templates/imaging.html +++ b/webapp/templates/imaging.html @@ -34,11 +34,18 @@ {% set border = 'danger' if is_failed else ('success' if is_done else 'primary') %}
-
- {{ s.serial or '(no serial)' }} - {% if s.hostname_target %}{{ s.hostname_target }}{% endif %} - {% if s.pctype %}{{ s.pctype }}{% endif %} - {% if s.machinenumber %}#{{ s.machinenumber }}{% endif %} +
+ {% if s.intune_device_id %} +
+ {% endif %} +
+ {{ s.serial or '(no serial)' }} + {% if s.hostname_target %}{{ s.hostname_target }}{% endif %} + {% if s.pctype %}{{ s.pctype }}{% endif %} + {% if s.machinenumber %}#{{ s.machinenumber }}{% endif %} + {% if s.intune_device_id %}
Intune: {{ s.intune_device_id }}
{% endif %} +
{{ s.status or 'in_progress' }}