Device identity, collector enrollment file, and network device fixes
This commit is contained in:
@@ -172,6 +172,7 @@ try {
|
||||
# 2. C:\Enrollment\cmm\cmmid.txt - CMM bay id (e.g. CMM3).
|
||||
# 3. C:\Enrollment\machine-number.txt - imaging value.
|
||||
# keyence / genspect / part-marker have no per-bay id -> no machineNo sent.
|
||||
# Those bays name their DEVICE instead, in asset-id.txt below.
|
||||
$machineNo = ''
|
||||
foreach ($regPath in @(
|
||||
'HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines\DNC\General',
|
||||
@@ -236,6 +237,45 @@ try {
|
||||
Log "WARN could not read logged-in user: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
# The DEVICE hanging off this PC - the ONE enrollment file for every bay that
|
||||
# has no NTLARS/eDNC MachineNo registry to identify it. It names the asset and
|
||||
# nothing else: it does not say what kind of device that is, because the pc-type
|
||||
# already does, so the same file serves a part marker, a Keyence, a Genspect or
|
||||
# anything added later without a new file or a client change.
|
||||
#
|
||||
# Deliberately NOT machine-number.txt. machinenumber answers "which bay is
|
||||
# this" and is what GE-Enforce TargetMachineNumbers gates on, so naming a device
|
||||
# there would silently stop every bay-gated manifest entry from matching.
|
||||
#
|
||||
# WHY A FILE AT ALL: every other identity the server can fall back to is derived
|
||||
# from the PC - a prior link from this PC, or an asset number built from this
|
||||
# hostname - so none of them survive a PC SWAP. The replacement box mints a
|
||||
# SECOND record for the same physical device while the first keeps its history
|
||||
# under a dead PC's name. This file is what survives.
|
||||
#
|
||||
# The server ADOPTS the named asset, refuses a value it cannot resolve, and
|
||||
# refuses one that resolves to the wrong kind of thing - so a typo warns instead
|
||||
# of inventing a phantom device.
|
||||
$deviceId = ''
|
||||
$idFile = 'C:\Enrollment\asset-id.txt'
|
||||
if (Test-Path -LiteralPath $idFile) {
|
||||
try {
|
||||
$deviceId = ([string](Get-Content -LiteralPath $idFile -First 1 -ErrorAction Stop)).Trim()
|
||||
if ($deviceId) { Log "deviceId from ${idFile}: $deviceId" }
|
||||
} catch { Log "WARN could not read ${idFile}: $($_.Exception.Message)" }
|
||||
}
|
||||
# 0.12.0 shipped measuringtool-id.txt before the file was generalised. Read it
|
||||
# as a fallback so a bay already staged with one keeps reporting.
|
||||
if (-not $deviceId) {
|
||||
$mtFile = 'C:\Enrollment\measuringtool-id.txt'
|
||||
if (Test-Path -LiteralPath $mtFile) {
|
||||
try {
|
||||
$deviceId = ([string](Get-Content -LiteralPath $mtFile -First 1 -ErrorAction Stop)).Trim()
|
||||
if ($deviceId) { Log "deviceId from ${mtFile} (pre-0.13 name): $deviceId" }
|
||||
} catch { Log "WARN could not read ${mtFile}: $($_.Exception.Message)" }
|
||||
}
|
||||
}
|
||||
|
||||
# imaging pc-type (gea-shopfloor-*), read from the enrollment file. Sent only
|
||||
# when present; absent -> server leaves existing pctype untouched (a bare report
|
||||
# never re-types a PC). Unmapped values return a warning, not an error.
|
||||
@@ -302,6 +342,7 @@ $body = @{ hostname = $hostname }
|
||||
if ($serialNumber) { $body['serialnumber'] = $serialNumber }
|
||||
if ($machineNo) { $body['machinenumber'] = $machineNo }
|
||||
if ($pcType) { $body['pctype'] = $pcType }
|
||||
if ($deviceId) { $body['deviceid'] = $deviceId }
|
||||
if ($manufacturer) { $body['vendorname'] = $manufacturer }
|
||||
if ($model) { $body['modelnumber'] = $model }
|
||||
if ($osVersion) { $body['osname'] = $osVersion }
|
||||
@@ -312,8 +353,8 @@ $body['lastcheckin'] = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:s
|
||||
|
||||
$json = $body | ConvertTo-Json -Compress -Depth 4
|
||||
|
||||
Log ("POST {0} host={1} serial={2} pcType={3} make={4} model={5} os={6} boot={7} machineNo={8} user={9} ip={10}" -f `
|
||||
$ApiUrl, $hostname, $serialNumber, $pcType, $manufacturer, $model, $osVersion, $lastBootTime, $machineNo, $loggedInUser, $corpIp)
|
||||
Log ("POST {0} host={1} serial={2} pcType={3} make={4} model={5} os={6} boot={7} machineNo={8} user={9} ip={10} deviceId={11}" -f `
|
||||
$ApiUrl, $hostname, $serialNumber, $pcType, $manufacturer, $model, $osVersion, $lastBootTime, $machineNo, $loggedInUser, $corpIp, $deviceId)
|
||||
|
||||
try {
|
||||
$resp = Invoke-RestMethod -Uri $ApiUrl -Method Post -Body $json `
|
||||
|
||||
Reference in New Issue
Block a user