Author Posts

July 6, 2017 at 1:11 pm

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.

July 6, 2017 at 1:23 pm

I think based on this link promptforchoice

Results are system.init32. Just need to confirm

July 7, 2017 at 2:12 am

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)