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] }