diff --git a/playbook/shopfloor-setup/common/GE-Enforce.ps1 b/playbook/shopfloor-setup/common/GE-Enforce.ps1 index 56603fc..36b0f2c 100644 --- a/playbook/shopfloor-setup/common/GE-Enforce.ps1 +++ b/playbook/shopfloor-setup/common/GE-Enforce.ps1 @@ -280,10 +280,26 @@ try { } } + # Prefer DNC reg (authoritative post-Update-MachineNumber) over + # machine-number.txt (imaging-time placeholder, often 9999 if tech + # imaged with placeholder + bay assignment came later). $machineNumber = '' try { - if (Test-Path 'C:\Enrollment\machine-number.txt') { - $machineNumber = (Get-Content 'C:\Enrollment\machine-number.txt' -First 1 -ErrorAction SilentlyContinue).Trim() + $regPaths = @( + 'HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines\Dnc\General', + 'HKLM:\SOFTWARE\GE Aircraft Engines\Dnc\General' + ) + foreach ($rp in $regPaths) { + if (Test-Path $rp) { + $v = (Get-ItemProperty -Path $rp -Name MachineNo -ErrorAction SilentlyContinue).MachineNo + if ($v -and $v -ne '9999') { $machineNumber = "$v"; break } + } + } + # Fall back to enrollment file (will be 9999 for placeholder PCs) + if (-not $machineNumber) { + if (Test-Path 'C:\Enrollment\machine-number.txt') { + $machineNumber = (Get-Content 'C:\Enrollment\machine-number.txt' -First 1 -ErrorAction SilentlyContinue).Trim() + } } } catch {}