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) <noreply@anthropic.com>
This commit is contained in:
@@ -636,6 +636,7 @@ function Invoke-RebootPrompt {
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
try {
|
try {
|
||||||
$qrText = Build-QRCodeText
|
$qrText = Build-QRCodeText
|
||||||
|
$qrRefreshed = [bool]($qrText -notmatch 'not yet Azure AD joined')
|
||||||
Invoke-IntuneSync
|
Invoke-IntuneSync
|
||||||
$lastSync = Get-Date
|
$lastSync = Get-Date
|
||||||
$nextRetrigger = $lastSync.AddMinutes($RetriggerMinutes)
|
$nextRetrigger = $lastSync.AddMinutes($RetriggerMinutes)
|
||||||
@@ -643,6 +644,14 @@ try {
|
|||||||
while ($true) {
|
while ($true) {
|
||||||
$snap = Get-Snapshot
|
$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
|
Clear-Host
|
||||||
Write-Host "=== Monitor running - transcript: $transcriptPath ===" -ForegroundColor DarkGray
|
Write-Host "=== Monitor running - transcript: $transcriptPath ===" -ForegroundColor DarkGray
|
||||||
foreach ($l in (Format-Snapshot -Snap $snap -LastSync $lastSync -NextRetrigger $nextRetrigger)) {
|
foreach ($l in (Format-Snapshot -Snap $snap -LastSync $lastSync -NextRetrigger $nextRetrigger)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user