Cmdlet
Read-ConsoleText
Asks for a line of text.
Syntax
Read-ConsoleText [-Default <String>] [-Description <String>] [-Height <Int32>] [-History <String[]>] [-MaxLength <Int32>] [-MaxLines <Int32>] [-MinLength <Int32>] [-Mode <Rich|Line|Accessible>] [-Multiline] [-ParameterName <String>] [-Pattern <String>] [-PatternMessage <String>] [-Placeholder <String>] [-Prefill] [-Required] [-Title] <String> [-Validate <ScriptBlock>] [<CommonParameters>]#Parameter set:
All Parameter SetsDescription
Asks for a line of text.
A default is shown as a hint (Enter on an empty box accepts it, Tab puts it in the box to edit). -Required, -MinLength, -MaxLength, -Pattern and -Validate check the answer; problems show inline under the box until fixed. -History offers earlier answers with Up and Down.
Examples
EXAMPLE 1
Read-ConsoleText -Title 'Value'Parameters
- -Default String
- The default answer.
- -Description String
- Help text under the question.
- -Height Int32
- The visible rows of the text area (-Multiline, default 6).
- -History String[]
- Earlier answers offered with Up and Down (oldest first).
- -MaxLength Int32
- The most characters.
- -MaxLines Int32
- The most lines (-Multiline).
- -MinLength Int32
- The fewest characters.
- -Mode InteractionMode
- Forces how to ask: Rich (in-place prompt), Line (question and typed answer), Accessible (numbered, no redraws) or None (use the default or fail).
- Possible values:
Rich,Line,Accessible - -Multiline SwitchParameter
- Asks for several lines of text in a text area: soft wrap, Enter for a new line, Ctrl+Enter (or Ctrl+S) to save, paste keeps line breaks. In line mode the answer ends with an empty line.
- -ParameterName String
- The parameter of your script that supplies this value without a prompt (named in the non-interactive error, for example -Domain).
- -Pattern String
- A regular expression the whole answer must match.
- -PatternMessage String
- The message when -Pattern does not match.
- -Placeholder String
- Muted text in the empty box.
- -Prefill SwitchParameter
- Puts the default in the box (editable) instead of showing it as a hint.
- -Required SwitchParameter
- Refuses an empty answer.
- -Title String
- The question.
- -Validate ScriptBlock
- A validator: $_ is the answer; return $true (or nothing) to accept, $false or an error message to refuse.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.