diff --git a/playbook/pxe_server_setup.yml b/playbook/pxe_server_setup.yml index 77136a5..6d56683 100644 --- a/playbook/pxe_server_setup.yml +++ b/playbook/pxe_server_setup.yml @@ -547,6 +547,7 @@ loop: - check-bios.cmd - models.txt + - hardware-report.ps1 ignore_errors: yes - name: "Deploy Dell Flash64W.exe to winpeapps/_shared/BIOS/" diff --git a/playbook/shopfloor-setup/BIOS/check-bios.cmd b/playbook/shopfloor-setup/BIOS/check-bios.cmd index b0916a4..adfbb10 100644 --- a/playbook/shopfloor-setup/BIOS/check-bios.cmd +++ b/playbook/shopfloor-setup/BIOS/check-bios.cmd @@ -6,6 +6,11 @@ set "BIOSDIR=%~dp0" set "FLASH=%BIOSDIR%Flash64W.exe" set "MANIFEST=%BIOSDIR%models.txt" +REM --- Report this machine to the PXE webapp (Hardware Coverage) --- +REM Every WinPE boot maps this share, whatever image is picked next, so this +REM is the one place that sees standard/engineer builds too. Best effort. +if exist "%BIOSDIR%hardware-report.ps1" powershell -NoProfile -ExecutionPolicy Bypass -File "%BIOSDIR%hardware-report.ps1" >NUL 2>&1 + if exist "%FLASH%" goto :flash_ok echo Flash64W.exe not found, skipping BIOS check. set "BIOS_STATUS=Skipped (Flash64W.exe missing)" diff --git a/playbook/shopfloor-setup/BIOS/hardware-report.ps1 b/playbook/shopfloor-setup/BIOS/hardware-report.ps1 new file mode 100644 index 0000000..6589f80 --- /dev/null +++ b/playbook/shopfloor-setup/BIOS/hardware-report.ps1 @@ -0,0 +1,59 @@ +# hardware-report.ps1 - Report this machine's hardware to the PXE webapp so +# its Hardware Coverage page can flag models with no driver pack or BIOS. +# +# Called by check-bios.cmd, which every WinPE boot runs from the BIOS share +# before the imaging menu. That is deliberate: the enrollment share (Y:, +# where winpe-status-push.ps1 lives) is never mapped on the gea-standard / +# gea-engineer path, so anything hung off Y: misses those builds. +# +# Sends the exact WMI model PESetup matches driver packs on, the Dell +# system SKU (what Dell's catalogs key on) and the BIOS version. Runs in +# WinPE's stripped PowerShell: wmic only, no CIM cmdlets. Best effort: +# logs to X:\Windows\Temp\hardware-report.log and never fails the boot. + +param( + [string]$PxeServer = $(if ($env:PXESERVER) { $env:PXESERVER } else { '172.16.9.1' }), + [int]$Port = 9009, + [int]$TimeoutSec = 5 +) + +$logFile = 'X:\Windows\Temp\hardware-report.log' +function Log { + param([string]$msg) + try { "$(Get-Date -Format s) $msg" | Out-File -FilePath $logFile -Append -Encoding utf8 } catch { } +} + +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 = Get-WmicValue 'bios' 'SerialNumber' + model = Get-WmicValue 'computersystem' 'Model' + manufacturer = Get-WmicValue 'computersystem' 'Manufacturer' + sku = Get-WmicValue 'computersystem' 'SystemSKUNumber' + bios_version = Get-WmicValue 'bios' 'SMBIOSBIOSVersion' +} +Log "model=$($hw.model) sku=$($hw.sku) bios=$($hw.bios_version) serial=$($hw.serial)" + +if (-not $hw.model) { + Log "no model - nothing to report" + exit 0 +} + +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 "OK http=$($resp.StatusCode)" +} catch { + Log "ERR $($_.Exception.Message)" +} + +exit 0 diff --git a/playbook/winpe-status-push.ps1 b/playbook/winpe-status-push.ps1 index 5226d48..9fba978 100644 --- a/playbook/winpe-status-push.ps1 +++ b/playbook/winpe-status-push.ps1 @@ -74,36 +74,4 @@ try { 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