I am attempting to write a script that will display a message box with yes/no buttons. I am wanting “Yes” to close an open application & “No” to end the script.
I have written a few mutations of the code below but the best I could get was both yes & no closed the application. Here’s my code:
Add-Type -AssemblyName PresentationCore,PresentationFramework
[System.Windows.MessageBox]::Show('Do you want to close TAS?',‘WARNING’,‘YesNo’)
[System.Windows.MessageBoxImage]::Warning
$msgBoxInput = [System.Windows.MessageBoxButton]::Show(‘YesNo’)
switch ($msgBoxInput) {
‘Yes’ {
Stop-Process -Name ATIS-Broadcaster2
‘YES’
}
‘No’ {
Exit-PSSession
‘NO’
}
}