Category: Forms/Prompts

Forms/PromptsGeneral

Yes/No Prompt

$yes = new-Object System.Management.Automation.Host.ChoiceDescription "&Yes","help" $no = new-Object System.Management.Automation.Host.ChoiceDescription "&No","help" $choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no) $answer = $host.ui.PromptForChoice("Prompt","Click yes to continue",$choices,0) if($answer -eq 0){ Write-Host "You clicked Yes" }elseif($answer -eq 1){ Write-Host "You clicked No" }