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:
@@ -1,4 +1,4 @@
|
||||
# 04-NetworkAndWinRM.ps1 — Set network profiles to Private and enable WinRM (baseline)
|
||||
# 04-NetworkAndWinRM.ps1 -- Set network profiles to Private and enable WinRM (baseline)
|
||||
|
||||
# --- Transcript ---
|
||||
$logDir = 'C:\Logs\SFLD'
|
||||
|
||||
@@ -336,7 +336,7 @@ function Add-ShopfloorToolsApps {
|
||||
$src = Find-ExistingLnk $app.SourceName
|
||||
if ($src) {
|
||||
# Skip if the sweep already moved the source into the
|
||||
# destination folder (src == dest → "cannot overwrite
|
||||
# destination folder (src == dest -> "cannot overwrite
|
||||
# the item with itself").
|
||||
if ((Resolve-Path -LiteralPath $src -ErrorAction SilentlyContinue).Path -eq
|
||||
(Join-Path $shopfloorToolsDir $app.SourceName)) {
|
||||
@@ -390,7 +390,7 @@ function Remove-EmptyCategoryFolders {
|
||||
# are delivered by DSC AFTER this initial shopfloor setup, so the first
|
||||
# run at imaging time won't find them (falls back to hardcoded URLs,
|
||||
# Plant Apps gets skipped). By calling 08 from inside 06, every SYSTEM
|
||||
# scheduled-task logon re-run of 06 also re-runs 08 — so after DSC drops
|
||||
# scheduled-task logon re-run of 06 also re-runs 08 -- so after DSC drops
|
||||
# the .url files and the next sweep files them into Web Links\, 08
|
||||
# picks them up and updates the Edge policy. Self-healing.
|
||||
# ============================================================================
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user