Skip to content

Read-SpectreConfirm

Description

Displays a simple confirmation prompt with the option of selecting yes or no. Additional options are provided to display either a success or failure response message in addition to the boolean return value.


Examples

Example 1
This example demonstrates a simple confirmation prompt with a success message.

Terminal window
$answer = Read-SpectreConfirm -Message "Would you like to continue the preview installation of [#7693FF]PowerShell 7?[/]" `
-ConfirmSuccess "Woohoo! The internet awaits your elite development contributions." `
-ConfirmFailure "What kind of monster are you? How could you do this?"
# Type "y", "↲" to accept the prompt
Write-Host "Your answer was '$answer'"

Parameters

Message

The prompt to display to the user. The default value is “Do you like cute animals?”.

TypeRequiredPositionPipelineInputAliases
[String]true1falseTitle
Question
Prompt

DefaultAnswer

The default answer to the prompt if the user just presses enter. The default value is “y”.

Valid Values:

  • y
  • n
  • none
TypeRequiredPositionPipelineInput
[String]false2false

ConfirmSuccess

The text and markup to display if the user chooses yes. If left undefined, nothing will display.

TypeRequiredPositionPipelineInput
[String]false3false

ConfirmFailure

The text and markup to display if the user chooses no. If left undefined, nothing will display.

TypeRequiredPositionPipelineInput
[String]false4false

TimeoutSeconds

TypeRequiredPositionPipelineInput
[Int32]false5false

Color

TypeRequiredPositionPipelineInput
[Color]false6false

Syntax

Terminal window
Read-SpectreConfirm [-Message] <String> [[-DefaultAnswer] <String>] [[-ConfirmSuccess] <String>] [[-ConfirmFailure] <String>] [[-TimeoutSeconds] <Int32>] [[-Color] <Color>] [<CommonParameters>]