Request-Choice
SYNOPSIS
Display a choice prompt to the user and return the selected option.
SYNTAX
Request-Choice [-Type] <String> [-Title] <String> [-Text] <String> [[-DefaultItem] <Int32>]
[<CommonParameters>]
DESCRIPTION
This function displays a choice prompt to the user with predefined options such as "YesNo", "OkCancel", or "RetryCancel". It allows customization of the title, text, and default selection. The function returns the label of the selected option.
EXAMPLES
EXAMPLE 1
Displays a Yes/No prompt with the title "Confirmation" and the text "Do you want to continue?".
EXAMPLE 2
Request-Choice -Type "OkCancel" -Title "Save Changes" -Text "Do you want to save changes?" -DefaultItem 2
Displays an Ok/Cancel prompt with "Cancel" as the default option.
PARAMETERS
-Type
Specifies the type of choice prompt. Valid values are: - AbortRetryIgnore - CancelTryAgainContinue - OkCancel - RetryCancel - YesNo - YesNoCancel
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Title
The title of the choice prompt.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Text
The text message displayed in the choice prompt.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-DefaultItem
The default option to be selected. Valid values are 1, 2, or 3. Defaults to 1.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: 1
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.