Powershell PromptForChoice?

Hallo.

Ich möchte gerne eine PowershellPromptForChoice haben. Sprich ich will, dass der Benutzer von dem Script eine Wahl hat welches Programm er installieren will. Es sollte drei Optionen geben. Ich habe schon etwas versucht aber es funktioniert nicht. Vielleicht kann mir jemand weiter helfen.

Der jetzige Code:

-------------------------------------------------------------------------------------------------------------------------------------

$title = "Anti-Virus installieren?"

$message = "            "

    $Nod32 = New-Object System.Management.Automation.Host.ChoiceDescription "&AV-Nod32"

        $Endpoint = New-Object System.Management.Automation.Host.ChoiceDescription "&Endpoint"

            $Nein = New-Object System.Management.Automation.Host.ChoiceDescription "&Nein"

                $options = [System.Management.Automation.Host.ChoiceDescription[]]($Nod32,$Endpoint, $Nein)

$result = $Host.ui.PromptForChoice($title, $message, $options, 0) 

switch ($result)

    {

        0 {"Nod32..."

           Start-Process X:\InstallFiles\nod32.exe   -whatif

          }

        1 {"Endpoint..."

          Start-Process X:\InstallFiles\entpoint.msi    -whatif

          }

        2 {"Nein..."}

          

    }

-------------------------------------------------------------------------------------------------------------------------------------

Computer, Windows, fehlercode, User, PowerShell

Meistgelesene Fragen zum Thema User