Imaging chain: Stage-Dispatcher + PPKG reboot + unattended sync_intune
Replaces the single-session "cancel PPKG reboot and cram everything into
one autologon" flow with a staged chain where each reboot advances to the
next step automatically. The technician touches the keyboard 3 times total
(UNPLUG prompt, Y to reboot, Configure-PC selections).
New Stage-Dispatcher.ps1:
Reads C:\Enrollment\setup-stage.txt and chains through:
shopfloor-setup -> sync-intune -> configure-pc
Each stage re-registers HKLM RunOnce so the dispatcher fires again on
the next logon. Stage file is deleted when the chain completes.
Transcript logged to C:\Logs\SFLD\stage-dispatcher.log.
Stage "shopfloor-setup": runs Run-ShopfloorSetup.ps1 (which reboots via
shutdown /r /t 10). Dispatcher advances stage to sync-intune in the
~10 second window before the machine goes down, re-registers RunOnce.
Stage "sync-intune": launches Monitor-IntuneProgress.ps1 -Unattended.
Exit 2 (pre-reboot done, user confirmed): dispatcher re-registers
RunOnce and initiates shutdown /r /t 5. Stage stays at sync-intune so
the monitor picks up post-reboot state on next boot.
Exit 0 (post-reboot install complete): dispatcher chains directly to
Configure-PC.ps1 in the same session, then deletes the stage file.
Stage "configure-pc": runs Configure-PC.ps1 and deletes the stage file.
Fallback entry point if the post-reboot chain was interrupted.
Modified run-enrollment.ps1:
Removed the shutdown /a that canceled the PPKG reboot. Instead writes
setup-stage.txt = "shopfloor-setup" and registers RunOnce for the
dispatcher. PPKG reboot fires naturally (handles PendingFileRename
operations like Zscaler rename and PPKG self-cleanup). Now tracked in
the git repo at playbook/shopfloor-setup/run-enrollment.ps1.
Modified Monitor-IntuneProgress.ps1:
New -Unattended switch. When set:
Invoke-SetupComplete exits 0 without waiting for keypress.
Invoke-RebootPrompt exits 2 without prompting or rebooting (dispatcher
handles both). Manual sync_intune.bat usage (no flag) unchanged.
RetriggerMinutes bumped from 3 to 5 (user request).
Modified startnet.cmd:
Now also copies Stage-Dispatcher.ps1 from the PXE server to
W:\Enrollment\Stage-Dispatcher.ps1 alongside run-enrollment.ps1.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,13 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[int]$PollSecs = 30,
|
||||
[int]$RetriggerMinutes = 3
|
||||
[int]$RetriggerMinutes = 5,
|
||||
# When set, the monitor exits with a status code instead of prompting
|
||||
# or rebooting. Used by Stage-Dispatcher.ps1 to keep control of the
|
||||
# imaging chain. Manual sync_intune.bat usage (no flag) stays interactive.
|
||||
# exit 0 = post-reboot install complete, all milestones reached
|
||||
# exit 2 = pre-reboot deployment done, reboot needed
|
||||
[switch]$Unattended
|
||||
)
|
||||
|
||||
# ============================================================================
|
||||
@@ -547,6 +553,11 @@ function Invoke-SetupComplete {
|
||||
Write-Host "========================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "The post-reboot DSC install phase is finished. The device is ready."
|
||||
|
||||
if ($Unattended) {
|
||||
Write-Host "(Unattended mode - returning to dispatcher)"
|
||||
exit 0
|
||||
}
|
||||
Wait-ForAnyKey
|
||||
exit 0
|
||||
}
|
||||
@@ -562,6 +573,15 @@ function Invoke-RebootPrompt {
|
||||
Write-Host "device-config.yaml and runs the per-app wrappers: Install-eDNC,"
|
||||
Write-Host "Install-UDC, Install-VCRedists, Install-OpenText, and so on."
|
||||
Write-Host ""
|
||||
|
||||
if ($Unattended) {
|
||||
# Dispatcher mode: exit with code 2 so the dispatcher can set
|
||||
# RunOnce before initiating the reboot itself.
|
||||
Write-Host "Pre-reboot complete. Returning to dispatcher (exit 2)." -ForegroundColor Yellow
|
||||
exit 2
|
||||
}
|
||||
|
||||
# Interactive mode (manual sync_intune.bat): prompt and reboot directly.
|
||||
Write-Host "Press Y to reboot now, or N to cancel: " -NoNewline -ForegroundColor Cyan
|
||||
$ans = Read-SingleKey -ValidKeys @('Y', 'N')
|
||||
Write-Host $ans
|
||||
|
||||
Reference in New Issue
Block a user