Replace all Unicode characters with ASCII in playbook scripts

Em dashes (U+2014) and arrows (U+2192) break PowerShell 5.1 on
Windows when the file has no UTF-8 BOM -- byte 0x94 gets read as
a right double quote in Windows-1252, silently closing strings
mid-parse. This caused run-enrollment.ps1 to fail on PXE-imaged
machines with "string is missing the terminator" at line 113.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-04-10 13:23:11 -04:00
parent fb5841eb20
commit c06310f5bd
7 changed files with 321 additions and 275 deletions

View File

@@ -52,12 +52,17 @@
param(
[int]$PollSecs = 30,
[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
# -Unattended: exit with status code instead of prompting/rebooting.
# Legacy flag kept for backward compatibility with manual testing.
[switch]$Unattended,
# -AsTask: runs as a persistent @logon scheduled task. On pre-reboot
# complete: reboots directly. On post-reboot complete: unregisters own
# task, launches ConfigureScript, exits. This is the primary mode for
# the imaging chain (registered by run-enrollment.ps1).
[switch]$AsTask,
# Path to Configure-PC.ps1, launched after post-reboot completion in
# -AsTask mode. Passed by the scheduled task's -ArgumentList.
[string]$ConfigureScript = ''
)
# ============================================================================
@@ -554,8 +559,22 @@ function Invoke-SetupComplete {
Write-Host ""
Write-Host "The post-reboot DSC install phase is finished. The device is ready."
if ($AsTask) {
# Task mode: unregister our own scheduled task, launch Configure-PC
Write-Host "Unregistering sync task..." -ForegroundColor Cyan
try {
Unregister-ScheduledTask -TaskName 'Shopfloor Intune Sync' -Confirm:$false -ErrorAction SilentlyContinue
} catch {}
if ($ConfigureScript -and (Test-Path -LiteralPath $ConfigureScript)) {
Write-Host "Launching Configure-PC..." -ForegroundColor Cyan
try { & $ConfigureScript } catch { Write-Warning "Configure-PC failed: $_" }
}
exit 0
}
if ($Unattended) {
Write-Host "(Unattended mode - returning to dispatcher)"
Write-Host "(Unattended mode - exiting)"
exit 0
}
Wait-ForAnyKey
@@ -574,11 +593,13 @@ function Invoke-RebootPrompt {
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
if ($AsTask -or $Unattended) {
# Task/unattended mode: reboot directly, no prompt.
# The task persists across the reboot -- it fires again on next
# logon and picks up the post-reboot monitoring phase.
Write-Host "Pre-reboot complete. Rebooting in 5 seconds..." -ForegroundColor Yellow
shutdown /r /t 5
exit 0
}
# Interactive mode (manual sync_intune.bat): prompt and reboot directly.