Fix Start-OSDCloud -ZTI blocking on image index prompt with -FindImageFile - #383
Open
kristofferkhansen wants to merge 2 commits into
Open
Fix Start-OSDCloud -ZTI blocking on image index prompt with -FindImageFile#383kristofferkhansen wants to merge 2 commits into
kristofferkhansen wants to merge 2 commits into
Conversation
…eFile Select-OSDCloudImageIndex always called Read-Host to pick an image index when a WIM contained more than one image, even when -ZTI was specified. This forced Start-OSDCloud -FindImageFile -ZTI into an interactive prompt during otherwise zero-touch deployments, requiring a stdin-piping workaround to answer it non-interactively. Select-OSDCloudImageIndex now accepts -ZTI and auto-selects the first image index (matching the existing ZTI defaulting pattern used elsewhere in Start-OSDCloud) instead of prompting.
Select-OSDCloudFileWim always called Read-Host to pick a WIM/ESD/SWM file under \OSDCloud\OS\, even with only one candidate present and even when -ZTI was set. On closed/EOF stdin, Read-Host returns '', and '' -ge 0 evaluates false, so the do/until loop spins forever instead of failing. In practice this is currently masked by piping a literal "1" into stdin, which is fragile: it silently answers a different question if a second qualifying image ever lands in \OSDCloud\OS\. Select-OSDCloudFileWim now accepts -ZTI. With exactly one candidate it auto-selects it (matching the existing single-index short-circuit in Select-OSDCloudImageIndex). With more than one candidate, it throws immediately instead of guessing which image to deploy or hanging on a starved prompt - picking the wrong file is worse than picking the wrong image index within a file, so this deliberately does not auto-pick the first result the way Select-OSDCloudImageIndex does. Start-OSDCloud.ps1 now passes -ZTI:$Global:StartOSDCloud.ZTI at the call site, same as the prior Select-OSDCloudImageIndex fix.
Author
|
Tested ok on my side. |
Author
|
Cross-referencing #259, which addresses part of the same problem — it auto-selects the WIM in Differences in scope:
If this merges, #259 could be closed as superseded. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #287
Problem
Start-OSDCloud -FindImageFile -ZTIstill blocks on interactive prompts, defeating fully zero-touch deployments. The only known workaround is piping stdin to answer them, e.g.:Two unguarded prompts are involved:
Select-OSDCloudFileWim— always prompts to pick a WIM/ESD/SWM file under\OSDCloud\OS\, even with a single candidate. On closed/EOF stdin,Read-Hostreturns'', and'' -ge 0evaluates false, so thedo/untilloop spins forever instead of failing.Select-OSDCloudImageIndex— always prompts to pick an image index whenever the selected WIM contains more than one image.Fix
Select-OSDCloudFileWim.ps1: add a-ZTIswitch. With exactly one file candidate, auto-select it. With more than one,throwimmediately rather than guessing which image to deploy or hanging on a starved prompt — picking the wrong file is worse than picking the wrong index within a file, so this deliberately does not auto-pick the first result.Select-OSDCloudImageIndex.ps1: add a-ZTIswitch. Auto-return the first image index instead of prompting (matches the value the communityecho 1workaround was already manually supplying).Start-OSDCloud.ps1: pass-ZTI:$Global:StartOSDCloud.ZTIat both call sites in the-FindImageFilepath.This mirrors the existing
$Global:StartOSDCloud.ZTIshort-circuit pattern already used elsewhere inStart-OSDCloud.ps1to skip prompts in ZTI mode.Start-OSDCloudCLI.ps1's call site forSelect-OSDCloudImageIndexis untouched (no-ZTIparam passed), so its interactive behavior is unaffected.Test plan
Parser.ParseFileon all changed files — no syntax errorsGet-WindowsImagereturning 2 images:Select-OSDCloudImageIndex -ZTIreturns the first index (1) with no promptFind-OSDCloudFilereturning 1 candidate:Select-OSDCloudFileWim -ZTIauto-selects it with no promptFind-OSDCloudFilereturning 2 candidates:Select-OSDCloudFileWim -ZTIthrows immediately instead of hanging or guessingStart-OSDCloud -Restart -ZTI -FindImageFile -SkipAutopilot -SkipODTrun against real media (not verified in this environment — no WinPE available)After this fix, the original command works without the
echo 1stdin workaround: