Tuesday, April 21, 2015

sample prompt

title = "Continue?"
$message = "If the settings are correct, Press Y to Continue?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Yes"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$choice=$host.ui.PromptForChoice($title, $message, $options, 1)

if ($choice -eq 1){Write-Warning "You pressed no.  Exiting script routine.";break}
Else { 'Do something Special }

No comments:

Post a Comment