Repository navigation
Add -DefaultValue parameter to Read-Host - #28464
Open
Zaid Ali Syed (zaidwhy) wants to merge 1 commit into
Open
Zaid Ali Syed (zaidwhy) wants to merge 1 commit into
Zaid Ali Syed (zaidwhy) wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Author
|
@microsoft-github-policy-service agree |
2 tasks done
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.
PR Summary
Add a
-DefaultValueparameter toRead-Hostso pressing Enter without typing anything returns the provided default value. Fixes #14013.PR Context
The Cmdlets working group agreed on this behavior on 2024-09-04. [SteveL-MSFT's comment](#14013 (comment)) discusses the agreed design.
With
-Prompt, the prompt displays likemyprompt (default: blue):. Without-Prompt, it displays(default: blue):. If the user presses Enter without entering anything, the default is returned. If they enter something, their input takes precedence.-MaskInputis currently allowed with-DefaultValue. Since the default comes from the script author, it is shown in plain text. If reviewers would prefer these parameters to be incompatible, I'm happy to change that.Testing
-Prompt, and incompatibility with-AsSecureString.Read-Hosttest files on Windows 11: 12 passed, 0 failed.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header