diff --git a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 index 729681b..94a3c4a 100644 --- a/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 +++ b/playbook/shopfloor-setup/Shopfloor/lib/Monitor-IntuneProgress.ps1 @@ -232,6 +232,7 @@ function Get-Phase1 { $reportIpLog = Get-ChildItem -Path 'C:\Logs\GE_Report_IP_Address*' -ErrorAction SilentlyContinue | Select-Object -First 1 $nicListFile = 'C:\Enrollment\disabled-wired-nics.txt' + $justReEnabled = $false if ($reportIpLog -and (Test-Path $nicListFile)) { try { $nicNames = Get-Content $nicListFile -ErrorAction Stop @@ -240,8 +241,13 @@ function Get-Phase1 { try { Enable-NetAdapter -Name $n -Confirm:$false -ErrorAction Stop } catch { Write-Warning "Enable-NetAdapter '$n' failed: $_" } } - Start-Sleep -Seconds 1 + # Wait for DHCP renewal + route table update + reachability to + # PXE server. 1 second wasn't enough in field testing - the + # subsequent idx=7 push fired into the void before the wired + # NIC was carrying traffic. + Start-Sleep -Seconds 5 Remove-Item $nicListFile -Force -ErrorAction SilentlyContinue + $justReEnabled = $true } catch { Write-Warning "Re-enable wired NICs failed: $_" } @@ -249,15 +255,26 @@ function Get-Phase1 { # Push DeviceId / idx=7 once, when both DeviceId is captured and the # Report IP log has landed (dashboard QR renders from DeviceId). + # Retry up to 6x with backoff because the imminent LAPS-prompt reboot + # gives us only seconds and the wired NIC may still be settling. if ($script:cache.DeviceId -and -not $script:cache.DeviceIdReported -and $reportIpLog) { Ensure-SendPxeStatus if (Get-Command Send-PxeStatus -ErrorAction SilentlyContinue) { - try { - Send-PxeStatus -Stage 'Monitor-IntuneProgress: Intune Device ID captured' ` - -StageIndex 7 -StageTotal 8 ` - -IntuneDeviceId $script:cache.DeviceId - $script:cache.DeviceIdReported = $true - } catch { } + $attempts = if ($justReEnabled) { 6 } else { 1 } + for ($i = 0; $i -lt $attempts; $i++) { + $err = $null + try { + Send-PxeStatus -Stage 'Monitor-IntuneProgress: Intune Device ID captured' ` + -StageIndex 7 -StageTotal 8 ` + -IntuneDeviceId $script:cache.DeviceId -ErrorAction Stop + $script:cache.DeviceIdReported = $true + break + } catch { $err = $_ } + if ($i -lt $attempts - 1) { Start-Sleep -Seconds 2 } + } + if (-not $script:cache.DeviceIdReported -and $err) { + Write-Warning "idx=7 push failed after $attempts attempts: $err" + } } }