Cmdlet
Read-ConsoleConfirm
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 SetsDescription
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
EXAMPLE 1
Read-ConsoleConfirm -Title 'Value'Parameters
- -Default Boolean
- The default answer.
- -Description String
- Help text under the question.
- -Destructive SwitchParameter
- Marks the question as destructive (a warning mark; No is focused unless -Default says otherwise).
- -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 - -NoText String
- The caption of the negative answer.
- -ParameterName String
- The parameter of your script that supplies this value without a prompt (named in the non-interactive error, for example -Domain).
- -Title String
- The question.
- -TypedConfirmation String
- The text the user must type to confirm.
- -YesText String
- 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.