Skip to content
ConsoleMonster
Cmdlet

Read-ConsoleConfirm

Module ConsoleMonster
Inputs
None
Outputs
System.Boolean

Asks a yes/no question and returns $true or $false.

Syntax

Read-ConsoleConfirm [-Default <Boolean>] [-Description <String>] [-Destructive] [-Mode <Rich|Line|Accessible>] [-NoText <String>] [-ParameterName <String>] [-Title] <String> [-TypedConfirmation <String>] [-YesText <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Asks a yes/no question and returns $true or $false.

Shows the question with the answers inline (the default focused); Y and N answer at once, arrows move, Enter takes the focused answer and Esc answers no. With -TypedConfirmation the user must type a text (a server name, a domain) before a destructive action; Esc then returns $false. In remoting and the ISE the host asks (PromptForChoice); without a user the default is returned.

Examples

Authored help example

EXAMPLE 1

Read-ConsoleConfirm -Title 'Value'

Parameters

-Default Boolean optional
The default answer.
-Description String optional
Help text under the question.
-Destructive SwitchParameter optional
Marks the question as destructive (a warning mark; No is focused unless -Default says otherwise).
-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
-NoText String optional
The caption of the negative answer.
-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).
-Title String requiredposition: 0aliases: Prompt, Question
The question.
-TypedConfirmation String optional
The text the user must type to confirm.
-YesText String optional
The caption of the positive answer.

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.