The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PSHostUserInterface.PromptForChoice Method (String, String, Collection(Of ChoiceDescription), Int32)


Updated: April 27, 2016

Applies To: Windows PowerShell

When overridden in a derived class, provides a set of choices that enable the user to choose a single option from a set of options.

Namespace:   System.Management.Automation.Host
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

Public MustOverride Function PromptForChoice (
	caption As String,
	message As String,
	choices As Collection(Of ChoiceDescription),
	defaultChoice As Integer
) As Integer


Type: System.String

The text that precedes (a title) the choices.

Type: System.String

A message that describes the choice.

Type: System.Collections.ObjectModel.Collection(Of ChoiceDescription)

A Collection(Of T) of ChoiceDescription objects that describe each choice.

Type: System.Int32

The index of the label in the choices parameter collection. These elements are displayed to the user as the default choices. To indicate no default choice, set to -1.

Return Value

Type: System.Int32

The index of the Choices parameter collection element that corresponds to the option that is selected by the user.

Exception Condition

The host can throw this exception when it cannot complete an operation.


If this method is not implemented, the host should throw a "not implemented" exception when it receives this call.


The host can throw this exception when an error occurs while a command is running.

To provide a set of choices that allow the user to select multiple choices, implement the IHostUISupportsMultipleChoiceSelection interface.

Return to top

Community Additions