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) <noreply@anthropic.com>
This commit is contained in:
@@ -201,15 +201,18 @@ function Ensure-SendPxeStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-Phase1 {
|
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 {
|
try {
|
||||||
$dsreg = dsregcmd /status 2>&1
|
$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
|
$script:cache.AzureAdJoined = $true
|
||||||
}
|
}
|
||||||
# Capture DeviceId once available. Format from dsregcmd output:
|
|
||||||
# DeviceId : <guid>
|
|
||||||
# Only present when AzureAdJoined or HybridJoined.
|
|
||||||
if (-not $script:cache.DeviceId -and $dsreg -match 'DeviceId\s*:\s*([0-9a-fA-F-]{30,})') {
|
if (-not $script:cache.DeviceId -and $dsreg -match 'DeviceId\s*:\s*([0-9a-fA-F-]{30,})') {
|
||||||
$script:cache.DeviceId = $matches[1]
|
$script:cache.DeviceId = $matches[1]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user