Prompt For Choice

  • Hi,

    I am very new to writing in powershell, so bear with me.

    My aim is to get a list of certificates and prompt the user to select which certificate they require. In my head I want the output

    0 Cert1

    1 Cert2

    3 Cert3

    Select your cert 0, 1, 2

    This is where I have got to from internet research. Appreciate any help.

    $caption = “Select the certificate you require”

    $message = “Select the desire certificate”

    $choices = [System.Management.Automation.Host.ChoiceDescription[]] `

    @(Get-ChildItem -path cert:\LocalMachine\My)

    [int]$defaultChoice = 0

    $choiceRTN = $host.ui.PromptForChoice($caption,$message, $choices,$defaultChoice)

  • What is or is not working?

    Do you have a specific problem?

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Hi,

    When the code is executed no results appear. Am I on the correct lines or completely wrong ?

  • Perhaps you could start with an example that works and change it line by line. The following's first example would be good to do that: http://www.zerrouki.com/powershell-menus-host-ui-promptforchoice-defined-or-dynamic/[/url].

    Perhaps you could post your results here to show everyone how you did.

    Also, feel free to come back with any other issues.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply