diff --git a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 index 0665b13..7b6e263 100644 --- a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 +++ b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 @@ -213,7 +213,12 @@ function Get-Phase1 { # 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 + # dsregcmd on Win11 emits ANSI escape codes (\x1B[7m...\x1B[0m) + # around field names when its output is treated as a terminal. + # Captured output then contains those codes between e.g. + # "DeviceId" and ":", breaking a tight regex like + # 'DeviceId\s*:\s*'. Strip ANSI sequences before matching. + $dsreg = (dsregcmd /status 2>&1 | Out-String) -replace '\x1B\[[0-9;]*[A-Za-z]', '' if (-not $script:cache.AzureAdJoined -and $dsreg -match 'AzureAdJoined\s*:\s*YES') { $script:cache.AzureAdJoined = $true }