# 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, so it reports every boot - including ones that # never pick an image - rather than only those that reach the Y: status push. # # 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