An MCL import merged Deploy/Applications with rsync -a, which replaced each image's BPRT symlink with a plain copy of the vendor folder. That copy has no site overlay, so standard/engineer enrollment lost Register-BulkEnrollTask-Standard.ps1 (specialize Order 39). Now Deploy/Applications is imported first and without BPRT: - where _shared/Applications/BPRT exists it is left alone (the BPRT page keeps it current) and the image link is put back; - on a box with none yet, the imported BPRT seeds it: vendor Select-PCConfig.ps1 kept as -vendor, our overlay added, BOM fix applied; - the import refuses before anything moves when that folder would not work (vendor scripts missing, or no overlay copy to add). The two Register scripts join Select-PCConfig.ps1 in the repo. The playbook already syncs shopfloor-setup to the enrollment share, so config.BPRT_OVERLAY_DIR finds all three there; overlay_sources now falls back to it for every overlay file, not only the shim.
43 lines
2.3 KiB
PowerShell
43 lines
2.3 KiB
PowerShell
# Register-BulkEnrollTask.ps1 - register the BulkEnrollmentOrchestrator logon task.
|
|
#
|
|
# WHY THIS IS A FILE AND NOT AN INLINE COMMAND
|
|
# This ran as an inline "powershell.exe -Command ..." in the unattend's
|
|
# specialize pass, at RunSynchronousCommand Order 16. The unattend schema caps
|
|
# RunSynchronousCommand/Path at 259 characters; the inline form had grown to 676,
|
|
# so Windows Setup rejected the WHOLE answer file:
|
|
#
|
|
# /settings/RunSynchronous/RunSynchronousCommand/[Order="16"]/Path
|
|
# Description = Value is invalid. hrResult = 0x80220005 pass = specialize
|
|
# "Windows could not parse or process unattend answer file ... The answer file
|
|
# is invalid."
|
|
#
|
|
# One over-length value blocks every pass, so the machine stops at a dialog with
|
|
# nothing configured. Every shopfloor build from 2026-08-05 evening onward failed
|
|
# this way. Keep the unattend's Path short and put logic here.
|
|
#
|
|
# PESetup's CopyPackages copies the whole of <media>\Deploy\Applications to the
|
|
# target before the image is applied, so this script is present at
|
|
# C:\Deploy\Applications\BPRT\ by the time specialize runs. See
|
|
# docs/PESETUP-INTERNALS.md.
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$taskName = 'BulkEnrollmentOrchestrator'
|
|
$orchestrator = 'C:\Deploy\Applications\BPRT\Start-BulkEnrollOrchestrator.ps1'
|
|
|
|
# Self-deleting task: schtasks /Delete removes the registration, then the
|
|
# orchestrator runs. cmd's & chains them so the delete happens even if the
|
|
# orchestrator later reboots the machine.
|
|
$argument = '/c schtasks /Delete /TN {0} /F & powershell.exe -NoProfile -ExecutionPolicy Bypass -File "{1}" -ManualFallback' -f $taskName, $orchestrator
|
|
|
|
$action = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument $argument
|
|
$trigger = New-ScheduledTaskTrigger -AtLogOn
|
|
# S-1-5-32-544 = BUILTIN\Administrators. GroupId + Highest so it runs elevated
|
|
# for whichever admin logs on first, without naming an account.
|
|
$principal = New-ScheduledTaskPrincipal -GroupId 'S-1-5-32-544' -RunLevel Highest
|
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Hours 3)
|
|
|
|
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force
|
|
|
|
Write-Host "Registered scheduled task '$taskName'."
|