“你确定吗?” 通过powershell中的消息框

Fea*_*der 3 forms powershell xaml

早安开发者,

我正在尝试在 powershell 中创建删除功能。我想要这样的东西:

  function deleteEnv(){
    $result = [System.Windows.Forms.MessageBox]::Show('Are you sure?''Yes', 'No' 'Info')
    if(yes){
     //Delete
}

else {
//do nothing
}
}
Run Code Online (Sandbox Code Playgroud)

当我单击删除按钮时,必须首先显示一个带有两个按钮是或否的消息框。如果是,则删除其他什么都不做。我怎样才能做到这一点?

亲切的问候

4c7*_*b41 5

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$result = [System.Windows.Forms.MessageBox]::Show('Are you sure?' , "Info" , 4)
if ($result -eq 'Yes') {
    do stuff
}
Run Code Online (Sandbox Code Playgroud)

补充阅读:http : //powershell-tips.blogspot.com.by/2012/02/display-messagebox-with-powershell.html