我想知道是否有人可以帮助我,我试图编译一个PS脚本,显示一个问题的弹出框,我希望它存储的答案,并返回给我。我设法得到这个脚本的弹出问题,但找不到返回答案的方法,这可能是通过发送电子邮件回也许?
Add-Type
-AssemblyName PresentationCore,PresentationFramework
$msgBody = "This is a question type your answer"
$msgTitle = "Confirm Reboot"
$msgButton = 'YesNoCancel'
$msgImage = 'Question'
$Result = [System.Windows.MessageBox]::Show($msgBody,$msgTitle,$msgButton,$msgImage)
Write-Host "The user chose: $Result [" ($result).value__ "]"
尝试了脚本的工作,需要的答案返回到我的电子邮件
1条答案
按热度按时间m528fe3b1#
根据我的评论。
这就是PowerShell邮件cmdlet允许您执行的操作。只需查看PowerShell控制台/伊势/VSCode示例中的帮助示例。请参阅邮件命令---
参见示例:
获取cmdlet详细信息:
找到要下载/安装和使用的邮件模块:
所以,根据你所说的。总而言之,它可能只是这样:
好吧,你还需要给予它一个邮件服务器。
根据我们最后的评论交流更新。
注意:我使用了一个名为***Variable Squeezing***的PowerShell功能,以便将值分配给变量并同时输出到屏幕上。这在代码中不需要执行您所要执行的操作,但它会在稍后的代码中处理变量内容之前显示变量内容。