goldy
July 6, 2017, 7:41am
1
Does my result switch statement have to be an indexed number or can it be words. The reason i’m asking is because if I have to make a change to the menu and insert a new option, I have to re-index the menu and its prone to error.
Any guidance would be great.
goldy
July 6, 2017, 7:53am
2
I think based on this link promptforchoice
Results are system.init32. Just need to confirm
You are correct
$host.ui|get-member|Format-List has this for the PromptForChoice method. All of the definitions are outputting as [int]
TypeName : System.Management.Automation.Internal.Host.InternalHostUserInterface
Name : PromptForChoice
MemberType : Method
Definition : int PromptForChoice(string caption, string message,
System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription] choices,
int defaultChoice), System.Collections.ObjectModel.Collection[int] PromptForChoice(string caption, string
message, System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription]
choices, System.Collections.Generic.IEnumerable[int] defaultChoices),
System.Collections.ObjectModel.Collection[int]
IHostUISupportsMultipleChoiceSelection.PromptForChoice(string caption, string message,
System.Collections.ObjectModel.Collection[System.Management.Automation.Host.ChoiceDescription] choices,
System.Collections.Generic.IEnumerable[int] defaultChoices)