The floor's 8 stages are the shopfloor pipeline, and only shopfloor-setup reports after WinPE, so every gea-standard / gea-engineer build sat at 1/8 forever with no type. - winpe-status-push.ps1 reads the image from the Z: share mapping when no PCTYPE is set and reports those builds as 5 steps. - Send-ImagingStage.ps1 (deployed to _shared\Applications\extra\pxe-status) posts steps 2-5 from the unattend: start and end of specialize, first logon, and setup complete (succeeded). It is copied to C:\ProgramData\PxeStatus first, because the bulk-enrollment task deletes C:\Deploy before first logon. Best-effort: always exits 0. - Floor rows use Standard/Engineer labels and show the image as the kind. Tested as SYSTEM in the win11 VM (PowerShell 5.1): the exact unattend command line, stages 3-5 against a test server, a dead port (exit 0), and the image regex.
74 lines
2.8 KiB
PowerShell
74 lines
2.8 KiB
PowerShell
# Send-ImagingStage.ps1 - posts one progress step of a gea-standard /
|
|
# gea-engineer build to the PXE webapp's /imaging/status endpoint, so the
|
|
# imaging floor follows these builds past WinPE (the shopfloor build has its
|
|
# own reporting in Shopfloor\lib\Send-PxeStatus.ps1).
|
|
#
|
|
# Called from the image's FlatUnattendW10.xml (specialize RunSynchronous and
|
|
# oobeSystem FirstLogonCommands). Deployed to
|
|
# _shared\Applications\extra\pxe-status\ on the PXE server, which PESetup
|
|
# copies to C:\Deploy\Applications\extra\pxe-status\.
|
|
#
|
|
# Best-effort: never blocks or fails Windows setup. Every error is swallowed,
|
|
# the script always exits 0, and each attempt is logged to
|
|
# C:\Logs\send-imaging-stage.log.
|
|
|
|
param(
|
|
[Parameter(Mandatory = $true)][string]$Stage,
|
|
[int]$StageIndex = 0,
|
|
[int]$StageTotal = 5,
|
|
[string]$PCType = '',
|
|
[ValidateSet('in_progress', 'succeeded', 'failed')][string]$Status = 'in_progress',
|
|
[string]$PxeServer = '172.16.9.1',
|
|
[int]$Port = 9009,
|
|
[int]$TimeoutSec = 5
|
|
)
|
|
|
|
$logFile = 'C:\Logs\send-imaging-stage.log'
|
|
function Log([string]$msg) {
|
|
try {
|
|
if (-not (Test-Path 'C:\Logs')) { New-Item -ItemType Directory -Path 'C:\Logs' -Force | Out-Null }
|
|
"$(Get-Date -Format s) $msg" | Out-File -FilePath $logFile -Append -Encoding utf8
|
|
} catch { }
|
|
}
|
|
|
|
try {
|
|
$serial = $null
|
|
try { $serial = (Get-CimInstance -ClassName Win32_BIOS -ErrorAction Stop).SerialNumber } catch {
|
|
try { $serial = (Get-WmiObject -Class Win32_BIOS -ErrorAction Stop).SerialNumber } catch { }
|
|
}
|
|
if ([string]::IsNullOrWhiteSpace($serial)) { $serial = $env:COMPUTERNAME }
|
|
$serial = ($serial -as [string]).Trim()
|
|
|
|
$mac = $null
|
|
try {
|
|
$nic = Get-NetAdapter -Physical -ErrorAction Stop |
|
|
Where-Object { $_.Status -eq 'Up' -and $_.MediaType -eq '802.3' } | Select-Object -First 1
|
|
if ($nic) { $mac = $nic.MacAddress -replace '-', ':' }
|
|
} catch { }
|
|
|
|
$payload = @{
|
|
serial = $serial
|
|
hostname_target = $env:COMPUTERNAME
|
|
current_stage = $Stage
|
|
stage_index = $StageIndex
|
|
stage_total = $StageTotal
|
|
status = $Status
|
|
}
|
|
if ($PCType) { $payload.pctype = $PCType }
|
|
if ($mac) { $payload.mac = $mac }
|
|
$body = $payload | ConvertTo-Json -Compress
|
|
$uri = "http://${PxeServer}:${Port}/imaging/status"
|
|
|
|
try {
|
|
$resp = Invoke-WebRequest -Uri $uri -Method POST -Body $body -ContentType 'application/json' `
|
|
-UseBasicParsing -TimeoutSec $TimeoutSec -ErrorAction Stop
|
|
Log "OK $($resp.StatusCode) $body"
|
|
} catch {
|
|
# Off the imaging network (or the server is down): nothing to report to.
|
|
Log "FAIL $($_.Exception.Message) $body"
|
|
}
|
|
} catch {
|
|
Log "ERROR $($_.Exception.Message)"
|
|
}
|
|
exit 0
|