From 2e8cf4b5be5fbee5ab8bc2c46b8c2ce321a46bc5 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Wed, 13 May 2026 14:35:18 -0400 Subject: [PATCH] Monitor-IntuneProgress: fix DeviceId capture gate DeviceId capture was nested inside the -not AzureAdJoined gate. Once AAD joined flipped true the block stopped running, but DeviceId only appears in dsregcmd output AFTER AzureAdJoined is set, so the capture never fired and Send-PxeStatus -IntuneDeviceId never pushed. Webapp session JSON missing intune_device_id field; /imaging card couldn't render the QR even though the bay-side Build-QRCodeText showed the QR correctly (it calls dsregcmd each render with no gate). Fix: change the gate condition so the dsregcmd call keeps running while EITHER AzureAdJoined OR DeviceId is still missing. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Shopfloor/lib/Monitor-IntuneProgress.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 index 3db4286..8045c60 100644 --- a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 +++ b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 @@ -201,15 +201,18 @@ function Ensure-SendPxeStatus { } function Get-Phase1 { - if (-not $script:cache.AzureAdJoined) { + # Re-run dsregcmd while EITHER AzureAdJoined OR DeviceId still missing. + # Previously the dsregcmd call was nested under -not AzureAdJoined alone; + # once AAD joined the block stopped running, but DeviceId only appears in + # dsregcmd output AFTER AzureAdJoined flips, so the capture never fired. + # Bay-side Build-QRCodeText calls dsregcmd each render which is why the + # on-screen QR works but the dashboard QR did not. + if (-not $script:cache.AzureAdJoined -or -not $script:cache.DeviceId) { try { $dsreg = dsregcmd /status 2>&1 - if ($dsreg -match 'AzureAdJoined\s*:\s*YES') { + if (-not $script:cache.AzureAdJoined -and $dsreg -match 'AzureAdJoined\s*:\s*YES') { $script:cache.AzureAdJoined = $true } - # Capture DeviceId once available. Format from dsregcmd output: - # DeviceId : - # Only present when AzureAdJoined or HybridJoined. if (-not $script:cache.DeviceId -and $dsreg -match 'DeviceId\s*:\s*([0-9a-fA-F-]{30,})') { $script:cache.DeviceId = $matches[1] }