Sixteen files that run on every shopfloor PC existed only on the SFLD share. The cost showed up while debugging the NTLARS backup: the script that posts to ShopDB could not be read, reviewed or diffed, so its behaviour was inferred from log output for most of a day. It turned out to hold a silent fallback that had been governing the whole fleet for months. Imported as-is from tsgwp00525-v2, no edits: lib/ShopdbBackupClient.psm1 the shared backup client scripts/Backup-NtlarsSettings.ps1 converted to use it scripts/Set-ShopdbCollectorKey.ps1 collector credential delivery scripts/Test-RegExport.ps1 exercises the .reg codec with mocks scripts/Set-EventSaver*.ps1 kiosk power / screensaver / disable scripts/Setup-OpenText.* OpenText install + toolbar scripts/Migrate-PCType.ps1, Select-KioskType.ps1, Set-FmsHostsEntry.ps1, scripts/ensure-vnc-firewall.ps1, Install-AcroReader.cmd, Install-Oracle11r2.cmd lib/Install-FromManifest.ps1 is also updated from the share, which was 37 lines AHEAD of this repo and purely additive: the Add-EnforceResult reporting added during the kiosk API cutover, done live and never committed back. Nothing was removed. Checked for embedded secrets before committing; there are none. Set-ShopdbCollectorKey deliberately reads its token from a sibling file on the share rather than holding it, so the script is safe to track. The share remains what actually runs. This makes it reviewable, and makes the next drift visible as a diff rather than a surprise.
47 lines
1.9 KiB
PowerShell
Executable File
47 lines
1.9 KiB
PowerShell
Executable File
# Set-FmsHostsEntry.ps1 - idempotently pin FMS host in C:\Windows\System32\drivers\etc\hosts.
|
|
#
|
|
# Why pinned:
|
|
# eDNC's FMS prescan (CPreScan::Initialise_Sockets in DncMain.exe and
|
|
# CDoPersonnel::InitializeSocket in DNCdll.dll) resolves the FMS host
|
|
# via MFC CSocket, which calls inet_addr first then gethostbyname. The
|
|
# legacy WinSock1 resolver path fails on the GE corporate network for
|
|
# wjfms3.ae.ge.com (modern getaddrinfo path used by PowerShell works
|
|
# fine, but eDNC does not use it). Hosts file entry is consulted by
|
|
# gethostbyname before any DNS query, so the pin short-circuits the
|
|
# broken legacy path.
|
|
#
|
|
# Idempotent: adds line if missing, leaves it alone if already present.
|
|
# Safe to run every cycle (DetectionMethod=Always in manifest).
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$hostsPath = Join-Path $env:windir 'System32\drivers\etc\hosts'
|
|
$ip = '10.233.112.158'
|
|
$fqdn = 'WJFMS3.AE.GE.COM'
|
|
$line = "$ip`t$fqdn"
|
|
|
|
if (-not (Test-Path $hostsPath)) {
|
|
Write-Host "hosts file not found at $hostsPath - aborting"
|
|
exit 1
|
|
}
|
|
|
|
$content = Get-Content -LiteralPath $hostsPath -ErrorAction Stop
|
|
|
|
# Match any non-comment line that maps either the IP or the FQDN.
|
|
# Drops stale or wrong mappings of the same FQDN/IP, then appends the canonical pin.
|
|
$pattern = '(?i)^\s*[^#\s]+\s+\S*' + [regex]::Escape($fqdn) + '\b|^\s*' + [regex]::Escape($ip) + '\s'
|
|
$existing = $content | Where-Object { $_ -match $pattern }
|
|
$canonical = ($existing | Where-Object { $_ -match "^\s*$([regex]::Escape($ip))\s+$([regex]::Escape($fqdn))\s*$" })
|
|
|
|
if ($canonical -and $existing.Count -eq @($canonical).Count) {
|
|
# Already pinned correctly. No change.
|
|
exit 0
|
|
}
|
|
|
|
# Either no entry, or an entry exists with wrong IP/FQDN/casing/whitespace. Rewrite.
|
|
$kept = $content | Where-Object { $_ -notmatch $pattern }
|
|
$new = @($kept) + $line
|
|
Set-Content -LiteralPath $hostsPath -Value $new -Encoding ascii -ErrorAction Stop
|
|
Write-Host "Wrote FMS hosts pin: $line"
|
|
exit 0
|