Files
pxe-server/playbook/shopfloor-setup/gea-shopfloor-waxtrace/resolve-bay-config.ps1
cproudlock 54dddaa760 Wax/Trace: per-bay FormTracePak version via bay-config.csv
Bays span 7 FormTracePak versions (5.510 - 6.213) and 3 sub-versions
(AVANT / CV-4500 / CV-3200), each with a unique licensing USER ID. Previously
all bays got v6.213 with no model/USER hint to the tech.

- bay-config.csv: 15 rows mapping asset_tag to ftpak_version + model + user_id.
- resolve-bay-config.ps1: WinPE-runnable resolver. Looks up the asset and
  writes version.txt / model.txt / userid.txt / bay-info.txt under
  W:\Enrollment\waxtrace\.
- startnet.cmd: xcopy WaxTrace bundle minus formtracepak\, invoke the
  resolver with %MACHINENUM%, then cherry-pick only the matching
  FORMTRACEPAK-V<ver>.iso (~2 GB local vs ~12 GB if all were staged).
- 09-Setup-WaxAndTrace.ps1: read the per-bay files, mount the right ISO,
  drop <asset>-FTPak-install-info.txt on SupportUser's desktop, and print
  a banner with MODEL + USER ID so the tech has them top-of-mind when
  Setup.exe dialogs come up.
- sync-waxtrace.sh: loop over all FORMTRACEPAK-V*.iso instead of hard-coding
  v6.213; also push bay-config.csv + resolve-bay-config.ps1 to the share.
2026-05-24 07:04:15 -04:00

91 lines
3.0 KiB
PowerShell

# resolve-bay-config.ps1 - WinPE-runnable bay-config resolver.
#
# Reads bay-config.csv (per-asset ftpak_version + model + user_id) and
# writes the matched row into per-field text files under $OutDir, so the
# rest of startnet.cmd + the post-imaging 09-Setup-WaxAndTrace.ps1 can
# read them as single-line files (cheaper than re-parsing CSV in batch).
#
# Outputs (under $OutDir, default W:\Enrollment\waxtrace\):
# version.txt - exact FormTracePak version (matches an installer ISO label)
# model.txt - sub-version (AVANT / CV-4500 / CV-3200)
# userid.txt - per-bay license USER ID
# bay-info.txt - human-readable audit dump (timestamped)
#
# Exit codes:
# 0 - row found + files written
# 1 - asset_tag not in bay-config.csv (Wax/Trace install will abort cleanly)
# 2 - bay-config.csv missing or unparseable
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$Asset,
[string]$ConfigCsv = '',
[string]$OutDir = 'W:\Enrollment\waxtrace'
)
# Default ConfigCsv: bay-config.csv next to this script on the share OR
# under the script's own directory in the local C:\WaxTrace-Install\ tree
# (depending on where the caller invokes us from).
if (-not $ConfigCsv) {
$cands = @(
(Join-Path $PSScriptRoot 'bay-config.csv'),
(Join-Path $PSScriptRoot '..\bay-config.csv'),
'Y:\installers-post\waxtrace\bay-config.csv',
'C:\WaxTrace-Install\bay-config.csv'
)
foreach ($c in $cands) {
if (Test-Path -LiteralPath $c) { $ConfigCsv = $c; break }
}
}
if (-not (Test-Path -LiteralPath $ConfigCsv)) {
Write-Warning "bay-config.csv not found (looked under $PSScriptRoot, ..\, Y:\installers-post\waxtrace\, C:\WaxTrace-Install\)"
exit 2
}
Write-Host "resolve-bay-config.ps1: looking up '$Asset' in $ConfigCsv"
try {
$rows = @(Import-Csv -LiteralPath $ConfigCsv)
} catch {
Write-Warning "Failed to parse ${ConfigCsv}: $_"
exit 2
}
$row = $rows | Where-Object { $_.asset_tag -ieq $Asset } | Select-Object -First 1
if (-not $row) {
Write-Warning "Asset '$Asset' not in $ConfigCsv. Available asset_tags: $(($rows.asset_tag | Sort-Object) -join ', ')"
exit 1
}
if (-not (Test-Path -LiteralPath $OutDir)) {
New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
}
function Write-Line {
param([string]$Name, [string]$Value)
$p = Join-Path $OutDir $Name
Set-Content -LiteralPath $p -Value $Value -NoNewline -Force
Write-Host " wrote $p = '$Value'"
}
Write-Line 'version.txt' $row.ftpak_version
Write-Line 'model.txt' $row.model
Write-Line 'userid.txt' $row.user_id
$infoLines = @(
"Bay-config resolved at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')",
" Asset: $($row.asset_tag)",
" FormTracePak: V$($row.ftpak_version)",
" Sub-version: $($row.model)",
" USER ID: $($row.user_id)",
"",
"Source: $ConfigCsv"
)
$infoPath = Join-Path $OutDir 'bay-info.txt'
Set-Content -LiteralPath $infoPath -Value ($infoLines -join "`r`n") -Force
Write-Host " wrote $infoPath"
Write-Host "resolve-bay-config.ps1: OK"
exit 0