imaging: renumber stages to be time-monotonic (1=WinPE, 7=Intune ID)
Previously the stage indices reflected logical milestones but not the order they fire in. Run-ShopfloorSetup posted idx=1 (start) and idx=4 (PPKG) - but 09-Setup-Keyence (inside per-type loop) ran BETWEEN them and posted idx=5/6. The dashboard then "regressed" from 6 back to 4 when PPKG fired, making it look stuck at the per-type-complete card. New numbering matches actual execution order: 1 - WinPE: PESetup / WIM apply (startnet.cmd) 2 - Run-ShopfloorSetup: starting (Run-ShopfloorSetup.ps1) 3 - 09-Setup-<Type>: starting (per-type) 4 - 09-Setup-<Type>: complete (per-type) 5 - Run-ShopfloorSetup: PPKG enrollment (Run-ShopfloorSetup.ps1) 6 - Run-ShopfloorSetup: handoff to Monitor (Run-ShopfloorSetup.ps1) 7 - Monitor-IntuneProgress: Intune Device ID captured services/imaging_status.py rewind threshold reverts to stage_index <= 1 now that WinPE startnet posts idx=1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,7 @@ Write-KeyenceLog "==============================================================
|
||||
# Status push to PXE webapp - best-effort, never blocks imaging.
|
||||
$pxeStatusLib = Join-Path $PSScriptRoot '..\Shopfloor\lib\Send-PxeStatus.ps1'
|
||||
if (Test-Path $pxeStatusLib) {
|
||||
try { . $pxeStatusLib; Send-PxeStatus -Stage '09-Setup-Keyence: starting' -StageIndex 5 -StageTotal 8 } catch { }
|
||||
try { . $pxeStatusLib; Send-PxeStatus -Stage '09-Setup-Keyence: starting' -StageIndex 3 -StageTotal 8 } catch { }
|
||||
}
|
||||
|
||||
# Diagnostic dump
|
||||
@@ -61,6 +61,61 @@ foreach ($file in @('pc-type.txt','pc-subtype.txt','machine-number.txt')) {
|
||||
}
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Step 0: Pre-stage Keyence VR Series USB driver + trust the publisher cert.
|
||||
# ============================================================================
|
||||
# The VR-6000 MSI invokes dpinst.exe internally as a custom action to install
|
||||
# the USB driver. dpinst inherits the MSI's silent context inconsistently and
|
||||
# usually pops a Setup-wizard GUI even with /qn on the parent MSI.
|
||||
#
|
||||
# Two pre-steps suppress the prompt:
|
||||
# 1. pnputil /add-driver /install stages the INF + co-installers into the
|
||||
# Windows DriverStore. dpinst then sees the driver as already present and
|
||||
# skips its install path (the GUI lives behind the "needs to install"
|
||||
# branch).
|
||||
# 2. Add the publisher cert (extracted from the catalog file) to
|
||||
# LocalMachine\TrustedPublisher so dpinst's "Would you like to install
|
||||
# this device software?" Windows Security dialog auto-accepts.
|
||||
#
|
||||
# If either step fails, log + continue - the MSI is still expected to install
|
||||
# successfully; the only fallout is the GUI prompt the operator would have
|
||||
# had to click through anyway.
|
||||
$driverInf = Join-Path $PSScriptRoot 'drivers\keyence_vr_series.inf'
|
||||
$driverCat = Join-Path $PSScriptRoot 'drivers\KEYENCE_VR_SERIES.cat'
|
||||
|
||||
if (Test-Path -LiteralPath $driverInf) {
|
||||
Write-KeyenceLog "Pre-staging USB driver via pnputil (suppresses dpinst GUI inside MSI)"
|
||||
try {
|
||||
$pnpOut = & pnputil /add-driver $driverInf /install 2>&1
|
||||
Write-KeyenceLog " pnputil exit $LASTEXITCODE"
|
||||
foreach ($line in ($pnpOut | Where-Object { $_ })) { Write-KeyenceLog " $line" }
|
||||
} catch {
|
||||
Write-KeyenceLog " pnputil failed: $_" 'WARN'
|
||||
}
|
||||
} else {
|
||||
Write-KeyenceLog "Driver INF not found at $driverInf - skipping pre-stage" 'WARN'
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $driverCat) {
|
||||
Write-KeyenceLog "Adding Keyence publisher cert to LocalMachine\TrustedPublisher store"
|
||||
try {
|
||||
$sig = Get-AuthenticodeSignature -FilePath $driverCat -ErrorAction Stop
|
||||
if ($sig -and $sig.SignerCertificate) {
|
||||
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store('TrustedPublisher','LocalMachine')
|
||||
$store.Open('ReadWrite')
|
||||
$store.Add($sig.SignerCertificate)
|
||||
$store.Close()
|
||||
Write-KeyenceLog " Added: $($sig.SignerCertificate.Subject) thumb=$($sig.SignerCertificate.Thumbprint)"
|
||||
} else {
|
||||
Write-KeyenceLog " Catalog is not signed - cert pre-trust skipped" 'WARN'
|
||||
}
|
||||
} catch {
|
||||
Write-KeyenceLog " Cert add failed: $_" 'WARN'
|
||||
}
|
||||
} else {
|
||||
Write-KeyenceLog "Driver catalog not found at $driverCat - cert pre-trust skipped" 'WARN'
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Step 1: Install via manifest (imaging-time)
|
||||
# ============================================================================
|
||||
@@ -75,6 +130,32 @@ if (-not (Test-Path $manifestPath)) {
|
||||
Write-KeyenceLog "Install-FromManifest returned $rc"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Step 1.5: Install Keyence-bundled DirectX End-User Runtimes
|
||||
# ============================================================================
|
||||
# VR-6000's MSI deploys DXSETUP.exe to the install dir but never runs it.
|
||||
# Without DirectX, the app's first launch errors: "Runtime required to move
|
||||
# the application is not installed correctly. Install from the following
|
||||
# folder: C:\Program Files\Keyence\VR-6000\Common\DirectX End-User Runtimes\
|
||||
# DXSETUP.exe". Run it silently here; /silent suppresses all UI + reboot.
|
||||
$dxSetup = 'C:\Program Files\KEYENCE\VR-6000\Common\DirectX End-User Runtimes\DXSETUP.exe'
|
||||
$dxSetupAlt = 'C:\Program Files (x86)\KEYENCE\VR-6000\Common\DirectX End-User Runtimes\DXSETUP.exe'
|
||||
if (Test-Path -LiteralPath $dxSetup) { $dxPath = $dxSetup }
|
||||
elseif (Test-Path -LiteralPath $dxSetupAlt) { $dxPath = $dxSetupAlt }
|
||||
else { $dxPath = $null }
|
||||
|
||||
if ($dxPath) {
|
||||
Write-KeyenceLog "Running DirectX End-User Runtimes: $dxPath /silent"
|
||||
try {
|
||||
$p = Start-Process -FilePath $dxPath -ArgumentList '/silent' -Wait -PassThru -NoNewWindow
|
||||
Write-KeyenceLog " DXSETUP exit $($p.ExitCode)"
|
||||
} catch {
|
||||
Write-KeyenceLog " DXSETUP failed: $_" 'WARN'
|
||||
}
|
||||
} else {
|
||||
Write-KeyenceLog "DXSETUP.exe not found under either Program Files - DirectX install skipped" 'WARN'
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Step 2: OpenText auto-start at login (HostExplorer "WJ Shopfloor" session)
|
||||
# ============================================================================
|
||||
@@ -89,7 +170,7 @@ if (Test-Path -LiteralPath $autoStartLib) {
|
||||
if (Get-Command Send-PxeStatus -ErrorAction SilentlyContinue) {
|
||||
$finalStatus = if ($rc -eq 0) { 'in_progress' } else { 'failed' }
|
||||
$finalErr = if ($rc -ne 0) { "Install-FromManifest exit $rc" } else { '' }
|
||||
Send-PxeStatus -Stage '09-Setup-Keyence: complete' -StageIndex 6 -StageTotal 8 -Status $finalStatus -Error_ $finalErr
|
||||
Send-PxeStatus -Stage '09-Setup-Keyence: complete' -StageIndex 4 -StageTotal 8 -Status $finalStatus -Error_ $finalErr
|
||||
}
|
||||
|
||||
Write-KeyenceLog "================================================================"
|
||||
|
||||
Reference in New Issue
Block a user