Donnerstag, 19. Mai 2016

Create user interface dynamically, where users can select from a choice

$patchNames = ("P1", "P2", "P3")  # You probably want to create that dynamically. This seems to be the whole point.
$patchIndex = -1
$patchOptions = @()
foreach ($patchName in $patchNames) {
      $patchIndex++
      $patchOptions += New-Object `
         System.Management.Automation.Host.ChoiceDescription `
         "${patchName}"
}
$options = [System.Management.Automation.Host.ChoiceDescription[]]$patchOptions
$patchIndex = $host.ui.PromptForChoice(
   "Patch-Auswahl",
   "Bitte den Patch anhand des Namens auswählen (z. B. Copy-Paste). " + `
   "Vorausgewählt ist der jüngste, der mit einfachem Enter-Drücken " + `
   "ausgewählt wird",
   $options,
   0
)
$patchName = $patchNames[${patchIndex}]

Keine Kommentare:

Kommentar veröffentlichen