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) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-05-13 15:41:52 -04:00
parent 320b241942
commit a8d38f6117
2 changed files with 23 additions and 14 deletions

View File

@@ -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 {

View File

@@ -34,11 +34,18 @@
{% set border = 'danger' if is_failed else ('success' if is_done else 'primary') %}
<div class="card border-{{ border }} mb-3">
<div class="card-header d-flex justify-content-between align-items-center">
<div class="d-flex align-items-center gap-3">
{% if s.intune_device_id %}
<div data-qr="{{ s.intune_device_id }}" data-qr-size="160" data-qr-ec="M" style="line-height:0;"
title="Intune Device ID: {{ s.intune_device_id }}"></div>
{% endif %}
<div>
<strong>{{ s.serial or '(no serial)' }}</strong>
{% if s.hostname_target %}<code class="ms-2 small text-muted">{{ s.hostname_target }}</code>{% endif %}
{% if s.pctype %}<span class="badge bg-info text-dark ms-2">{{ s.pctype }}</span>{% endif %}
{% if s.machinenumber %}<span class="badge bg-secondary ms-1">#{{ s.machinenumber }}</span>{% endif %}
{% if s.intune_device_id %}<div class="small text-muted mt-1">Intune: <code>{{ s.intune_device_id }}</code></div>{% endif %}
</div>
</div>
<span class="badge bg-{{ border }}">{{ s.status or 'in_progress' }}</span>
</div>