Skip to content

Instantly share code, notes, and snippets.

@numbnet
Created May 21, 2021
Embed
What would you like to do?
##**********************************************************
##
$title = "Lorem"
$message = "Ipsum"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "This means Yes"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "This means No"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $Options, 0)
Switch ($result) {
0 { "You just said Yes" }
1 { "You just said No" }
}
##**********************************************************
##
while( -not ( ($choice= (Read-Host "May I continue?")) -match "y|n")){ "Y or N ?"}
##**********************************************************
##
$confirmation = Read-Host "Ready? [y/n]"
while($confirmation -ne "y")
{
if ($confirmation -eq 'n') {exit}
$confirmation = Read-Host "Ready? [y/n]"
}
Write-Host 'Confirmed'
##**********************************************************
##
$decision = $Host.UI.PromptForChoice('something', 'Are you sure you want to proceed?', @('&Yes'; '&No'), 1)
##**********************************************************
##
Read-Host -Prompt "Press any key to continue or CTRL+C to quit"
##**********************************************************
##
$title = 'something'
$question = 'Are you sure you want to proceed?'
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes'))
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No'))
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
if ($decision -eq 0) {
Write-Host 'confirmed'
} else {
Write-Host 'cancelled'
}
##**********************************************************
##
$title = 'something'
$question = 'Are you sure you want to proceed?'
$choices = '&Yes', '&No'
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
if ($decision -eq 0) {
Write-Host 'confirmed'
} else {
Write-Host 'cancelled'
}
##**********************************************************
##
# SilentlyContinue;Stop;Continue;Inquire;Ignore;Suspend
Write-Warning "$env:ComputerName" -WarningAction Inquire
##**********************************************************
##
$a = new-object -comobject wscript.shell
$b = ${a}.popup("This is a test",0, "Test Message Box",1)
##**********************************************************
##
function Get-SomeInput {
$ASK = "Write [yes/no] and press Enter"
$Again = "You ${ASK}, please try Again!";
$input = read-host ${ASK};
switch ($input) {
"yes" {write-host "Yes"}
"no" {write-host "No "}
default {write-host "${Again}";Get-SomeInput}
}
}
Get-SomeInput
##**********************************************************
##
$reply = Read-Host -Prompt "Continue?[y/n]"
if ( $reply -match "[YESyesYyНУЫнуыНн]" ) {
write-host "*** YES ***"
} else {
write-host "*** NO ***"; break
}
write-host "*** XX ***"
##**********************************************************
##
$confirmation = Read-Host "Are you Sure?[y/n]"
if ($confirmation -eq "Y") {
write-host "*** YES ***"; break
}
write-host "*** NO ***"; break
##**********************************************************
##
$confirmation = Read-Host "Are you Sure?[y/n]"
if ($confirmation -eq "Y") {
Write-Host '*** Yes ***'
} else {
Write-Host '*** No ***'
}
write-host "NEXT"
##**********************************************************
##
$shell = new-object -comobject "WScript.Shell"
$choice = $shell.popup("Insert question here",0,"Popup window title",4+32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment