From 15f67063bd3952b1947837e85ace62e789b1d455 Mon Sep 17 00:00:00 2001 From: cproudlock Date: Fri, 10 Apr 2026 14:38:15 -0400 Subject: [PATCH] Refresh QR code after AAD join detected The QR code text was built once at script startup. If the device wasn't AAD-joined yet, it showed "Device not yet Azure AD joined" forever - even after Phase 1 checks passed. Now regenerates Build-QRCodeText when Phase1.AzureAdJoined transitions to true. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Shopfloor/lib/Monitor-IntuneProgress.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 index e1137f8..1d61f85 100644 --- a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 +++ b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 @@ -636,6 +636,7 @@ function Invoke-RebootPrompt { # ============================================================================ try { $qrText = Build-QRCodeText + $qrRefreshed = [bool]($qrText -notmatch 'not yet Azure AD joined') Invoke-IntuneSync $lastSync = Get-Date $nextRetrigger = $lastSync.AddMinutes($RetriggerMinutes) @@ -643,6 +644,14 @@ try { while ($true) { $snap = Get-Snapshot + # Refresh QR code once AAD join is detected (the initial build + # may have run before enrollment completed, showing "not yet + # Azure AD joined" even after Phase 1 passes). + if (-not $qrRefreshed -and $snap.Phase1.AzureAdJoined) { + $qrText = Build-QRCodeText + $qrRefreshed = $true + } + Clear-Host Write-Host "=== Monitor running - transcript: $transcriptPath ===" -ForegroundColor DarkGray foreach ($l in (Format-Snapshot -Snap $snap -LastSync $lastSync -NextRetrigger $nextRetrigger)) {