fix: resolve cmd.exe quoting and stdin issues in Invoke-MaskedProcess#110
Merged
Conversation
When Invoke-MaskedProcess runs inside Start-Job (a separate process), two issues caused failures on Windows: 1. RedirectStandardInput was false, so child processes inherited a broken stdin handle from the job's consoleless process, causing Python (az CLI) to hang on startup. Fixed by redirecting stdin and closing it immediately. 2. ArgumentList individually quotes each argument, but cmd.exe /c has its own quoting rules that conflict. Paths with spaces (C:\Program Files\...) broke, and metacharacters like parentheses in JMESPath queries were interpreted as cmd.exe grouping operators. Fixed by using the Arguments string property with proper quoting for the cmd.exe /c case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EMaher
approved these changes
Jun 5, 2026
EMaher
approved these changes
Jun 5, 2026
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.
Summary
Fixes two Windows-specific bugs in
Invoke-MaskedProcess(LogMasking.psm1) that caused integration test failures when the deploy scripts runazcommands insideStart-Job.Changes
1. Stdin redirect hang fix
RedirectStandardInputwas$false, so child processes spawned insideStart-Job(which has no parent console) inherited a broken stdin handle. Python (theazCLI runtime) hung on startup waiting for stdin initialization.Fix: Set
RedirectStandardInput = $trueand close stdin immediately afterStart().2. cmd.exe
/cargument quoting fixArgumentListindividually quotes each argument using C-runtime conventions, butcmd.exe /chas its own incompatible quoting rules:C:\Program Files\...) broke becausecmd.exestripped individual quotes and split at the space →'C:\Program' is not recognizedlength(value[?name=='...'])) were interpreted as cmd.exe grouping operators →--output was unexpected at this time.Fix: For the
cmd.exe /ccase, use theArgumentsstring property instead ofArgumentList, with each argument individually quoted inside an outer/c "..."wrapper. This ensures cmd.exe passes all content through as literals.Testing
az account showworks insideStart-Job(previously hung indefinitely)