CLOSE

How Can I Give a User a Yes/No Prompt in Powershell

You are here:
< Back

# Purpose: How Can I Give a User a Yes/No Prompt in Powershell?

$a = new-object -comobject wscript.shell
$intAnswer = $a.popup(“Do you want to delete these files?”, `
0,”Delete Files”,4)
If ($intAnswer -eq 6) {
$a.popup(“You answered yes.”)
} else {
$a.popup(“You answered no.”)
}

#Button Types
#
#Value Description
#0 Show OK button.
#1 Show OK and Cancel buttons.
#2 Show Abort, Retry, and Ignore buttons.
#3 Show Yes, No, and Cancel buttons.
#4 Show Yes and No buttons.
#5 Show Retry and Cancel buttons.