Powershell-提示用户在xx秒后提示过期

Powershell-提示用户在xx秒后提示过期,powershell,timer,prompt,timed,Powershell,Timer,Prompt,Timed,我试图为用户操作显示promp,如果没有执行任何操作,请关闭提示并继续执行脚本。这是我的命令提示符对话框配置 我在互联网上到处寻找,我看到了这一点在C#中的实现,但就我个人而言,我无法确定powershell的最佳方法。我将感谢任何帮助 多谢各位 编辑:谢谢你诺亚,这是更新的代码,它甚至更紧凑了 $prompt=新对象-comobject wscript.shell $answer=$prompt.popup(“您想做什么吗?`n',5,“title”,3) 如果($answer-eq 6)

我试图为用户操作显示promp,如果没有执行任何操作,请关闭提示并继续执行脚本。这是我的命令提示符对话框配置



我在互联网上到处寻找,我看到了这一点在C#中的实现,但就我个人而言,我无法确定powershell的最佳方法。我将感谢任何帮助

多谢各位

编辑:谢谢你诺亚,这是更新的代码,它甚至更紧凑了

$prompt=新对象-comobject wscript.shell
$answer=$prompt.popup(“您想做什么吗?`n',5,“title”,3)
如果($answer-eq 6){选择了Write Host“Yes”}
如果($answer-eq 7){选择了写入主机“否”}
如果($answer-eq-1){写入主机“超时”}
如果($answer-eq 2){Write Host“已被用户取消”。}

给你……从我的一个旧脚本中找到了这个

#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. 
#http://msdn.microsoft.com/en-us/library/x83z1d9f(v=vs.84).aspx

$a = new-object -comobject wscript.shell 
$intAnswer = $a.popup("Question?",2,"Title",4) #first number is timeout, second is display.

#7 = no , 6 = yes, -1 = timeout

哇,我从没想过要使用wscript.shell对象。谢谢你,诺亚!对我来说,这不适用于超过19秒的值:
#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. 
#http://msdn.microsoft.com/en-us/library/x83z1d9f(v=vs.84).aspx

$a = new-object -comobject wscript.shell 
$intAnswer = $a.popup("Question?",2,"Title",4) #first number is timeout, second is display.

#7 = no , 6 = yes, -1 = timeout