Files
pxe-server/playbook/winpe-status-push.ps1
cproudlock b691a82530 Hardware coverage: flag models the server has no drivers or BIOS for
WinPE now reports each machine's WMI model, manufacturer, Dell system
SKU and BIOS version to /hardware/seen (winpe-status-push.ps1, best
effort, wmic only). The webapp records every model seen and checks it
against what the server has:
  - each image's Deploy/Control/HardwareDriver.json, matched exactly as
    PESetup's GetDriverByModel does (as reimplemented in
    lint-driver-catalogue.py), plus whether the pack's zip is on disk;
  - the WinPE BIOS manifest (substring match like check-bios.cmd).

/hardware lists every model with per-image driver status and BIOS
status. A model missing a Win11 pack or a BIOS entry becomes item 5 on
the Technician To-Do (and the banner count) until the pack/BIOS is added
or it is dismissed. Virtual machines are ignored.

Also deploys the repo winpe-status-push.ps1 over the live copy, which
predated the -CurrentStage/-StageIndex parameters startnet.cmd passes
for the BIOS-flash stage, so that status post was failing.
2026-10-09 09:23:52 -04:00

110 lines
3.8 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,
[string]$CurrentStage = 'WinPE: PESetup / WIM apply',
[int]$StageIndex = 1
)
$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 = $CurrentStage
stage_index = $StageIndex
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)"
}
# Hardware facts for the webapp's driver/BIOS coverage check (/hardware):
# the exact WMI model PESetup matches driver packs on, the Dell system SKU
# (what Dell's catalogs key on), and the BIOS version check-bios.cmd sees.
function Get-WmicValue {
param([string]$Class, [string]$Property)
try {
$line = (& wmic $Class get $Property /value 2>$null |
Where-Object { $_ -match '=' } | Select-Object -First 1)
if ($line) { return ($line -split '=', 2)[1].Trim() }
} catch { Log "wmic $Class $Property exception: $_" }
return ''
}
$hw = @{
serial = $serial
model = Get-WmicValue 'computersystem' 'Model'
manufacturer = Get-WmicValue 'computersystem' 'Manufacturer'
sku = Get-WmicValue 'computersystem' 'SystemSKUNumber'
bios_version = Get-WmicValue 'bios' 'SMBIOSBIOSVersion'
pctype = $PCType
}
Log "hardware model=$($hw.model) sku=$($hw.sku) bios=$($hw.bios_version)"
if ($hw.model) {
try {
$resp = Invoke-WebRequest -Uri "http://${PxeServer}:${Port}/hardware/seen" -Method POST `
-Body ($hw | ConvertTo-Json -Compress) -ContentType 'application/json' `
-UseBasicParsing -TimeoutSec $TimeoutSec -ErrorAction Stop
Log "hardware OK http=$($resp.StatusCode)"
} catch {
Log "hardware ERR $($_.Exception.Message)"
}
}
exit 0