Files
pxe-server/playbook/winpe-status-push.ps1
cproudlock ce604adcda Renumber PXE LAN from 10.9.100.0/24 to 172.16.9.0/24
Single-site bay-stuck issue at WJ: GE Intune Report IP script filters
Get-NetIPAddress on StartsWith("10.") and posts everything matching
to the GE Tines webhook. Bays at WJ get the PXE LAN 10.9.100.x IP
captured and reported -> GE backend tags bays as on a non-corp 10.x
subnet -> dynamic group eligibility for SFLD policy never matches.
Other GE sites work because their PXE LANs aren't on 10.x at all.

Renumber PXE LAN to RFC1918 172.16.9.0/24 so the GE filter naturally
skips wired PXE addresses without any disable-NIC dance.

Server-side already in flight (netplan dual-bound, dnsmasq scope +
boot URL repointed, blancco preferences + grub.cfg + iPXE GetPxeScript
all sed'd to 172.16.9.1). This commit is the playbook / scripts /
docs side: 109 hits across 35 files sed'd in one shot.

After this lands + boot.wim is rebuilt + bays renumber off DHCP,
the 10.9.100.1 binding will be dropped from netplan as the final
cleanup step.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 16:30:32 -04:00

76 lines
2.4 KiB
PowerShell

# winpe-status-push.ps1 - Posts "WinPE: PESetup / WIM apply" status to the
# PXE webapp /imaging/status endpoint so the imaging dashboard reflects
# this bay BEFORE Run-ShopfloorSetup.ps1 takes over post-PPKG.
#
# Runs in WinPE's stripped PowerShell - cannot rely on Get-NetAdapter,
# Get-CimInstance, or the NetTCPIP module (none are present in stock
# WinPE). Uses wmic for both serial and MAC.
#
# Best-effort: never blocks imaging. All steps log to
# X:\Windows\Temp\winpe-status-push.log; failures are swallowed.
param(
[string]$PxeServer = '172.16.9.1',
[int]$Port = 9009,
[int]$TimeoutSec = 5,
[string]$PCType = $env:PCTYPE
)
$logFile = 'X:\Windows\Temp\winpe-status-push.log'
function Log {
param([string]$msg)
try { "$(Get-Date -Format s) $msg" | Out-File -FilePath $logFile -Append -Encoding utf8 } catch { }
}
Log "=== winpe-status-push start ==="
Log "server=${PxeServer}:${Port} pctype=$PCType"
# Serial via wmic. Always available in WinPE 10+.
$serial = ''
try {
$line = (& wmic bios get serialnumber /value 2>$null | Where-Object { $_ -match '=' } | Select-Object -First 1)
if ($line) { $serial = ($line -split '=', 2)[1].Trim() }
} catch { Log "serial wmic exception: $_" }
Log "serial=$serial"
# MAC via wmic NIC enumeration. NetEnabled filter restricts to up adapters.
$mac = ''
try {
$macLines = & wmic nic where 'NetEnabled=TRUE' get MacAddress /value 2>$null |
Where-Object { $_ -match 'MacAddress=' }
if ($macLines) {
$first = ($macLines | Select-Object -First 1)
$mac = (($first -split '=', 2)[1]).Trim() -replace '-', ':'
}
} catch { Log "mac wmic exception: $_" }
Log "mac=$mac"
if (-not $serial) {
Log "no serial captured - aborting POST"
exit 0
}
# Compose JSON. ConvertTo-Json works in WinPE.
$payload = @{
serial = $serial
pctype = $PCType
current_stage = 'WinPE: PESetup / WIM apply'
stage_index = 1
stage_total = 8
status = 'in_progress'
}
if ($mac) { $payload.mac = $mac }
$body = $payload | ConvertTo-Json -Compress
$uri = "http://${PxeServer}:${Port}/imaging/status"
Log "POST $uri body=$body"
try {
$resp = Invoke-WebRequest -Uri $uri -Method POST -Body $body `
-ContentType 'application/json' -UseBasicParsing -TimeoutSec $TimeoutSec -ErrorAction Stop
Log "OK http=$($resp.StatusCode)"
} catch {
Log "ERR $($_.Exception.Message)"
}
exit 0