< Back

Get-PSFUserChoice

Sun Jan 19, 2020 6:41 pm

NAME Get-PSFUserChoice



SYNOPSIS

Prompts the user to choose between a set of options.





SYNTAX

Get-PSFUserChoice [-Options] <Object[]> [[-Caption] <String>] [[-Message] <String>] [[-DefaultChoice] <Int32>]

[<CommonParameters>]





DESCRIPTION

Prompts the user to choose between a set of options.

Returns the index of the choice picked as a number.





PARAMETERS

-Options <Object[]>

The options the user may pick from.

The user selects a choice by specifying the letter associated with a choice.

The letter assigned to a choice is picked from the character after the first '&' in any specified string.

If there is no '&', the system will automatically pick the first letter as choice letter:

"This &is an example" will have the character "i" bound for the choice.

"This is &an example" will have the character "a" bound for the choice.

"This is an example" will have the character "T" bound for the choice.



This parameter takes both strings and hashtables (in any combination).

A hashtable is expected to have two properties, 'Label' and 'Help'.

Label is the text shown in the initial prompt, help what the user sees when requesting help.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Caption <String>

The title of the question, so the user knows what it is all about.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Message <String>

A message to offer to the user. Be more specific about the implications of this choice.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DefaultChoice <Int32>

The index of the choice made by default.

By default, the first option is selected as default choice.



Required? false

Position? 4

Default value 0

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.Int32





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-PSFUserChoice -Options "1) Create a new user", "2) Disable a user", "3) Unlock an account", "4) Get a

cup of coffee", "5) Exit" -Caption "User administration menu" -Message "What operation do you want to perform?"



Prompts the user for what operation to perform from the set of options provided











RELATED LINKS