Skip to content
ConsoleMonster
Cmdlet

Read-ConsoleText

Module ConsoleMonster
Inputs
None
Outputs
System.String

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 Sets

Description

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

Authored help example

EXAMPLE 1

Read-ConsoleText -Title 'Value'

Parameters

-Default String optional
The default answer.
-Description String optional
Help text under the question.
-Height Int32 optional
The visible rows of the text area (-Multiline, default 6).
-History String[] optional
Earlier answers offered with Up and Down (oldest first).
-MaxLength Int32 optional
The most characters.
-MaxLines Int32 optional
The most lines (-Multiline).
-MinLength Int32 optional
The fewest characters.
-Mode InteractionMode optional
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 optional
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 optionalaliases: Parameter
The parameter of your script that supplies this value without a prompt (named in the non-interactive error, for example -Domain).
-Pattern String optional
A regular expression the whole answer must match.
-PatternMessage String optional
The message when -Pattern does not match.
-Placeholder String optional
Muted text in the empty box.
-Prefill SwitchParameter optional
Puts the default in the box (editable) instead of showing it as a hint.
-Required SwitchParameter optional
Refuses an empty answer.
-Title String requiredposition: 0aliases: Prompt, Question
The question.
-Validate ScriptBlock optional
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.