PowerShell GUI Boxes - how to use GUI display boxes in powershell

Опубликовано: 30 Сентябрь 2024
на канале: x-wiki
2,571
32

PowerShell GUI Boxes - how to use GUI display boxes in PowerShell

In this video, you can learn how to use GUI input boxes in PowerShell Scripts and how to display error/warning/information display boxes.
It has also a sample script to show how it can be used. Below is the reference URL mentioned in the video and actual code as well :-)



[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic'

inputbox
$MessageBody = "Sample Message"
$MessageTitle = "Test Title"
$Result = [Microsoft.VisualBasic.Interaction]::InputBox($MessageBody, $MessageTitle)


Error/Warning/Information box
$ButtonType_ok = [System.Windows.MessageBoxButton]::ok
$ButtonType_yesno = [System.Windows.MessageBoxButton]::yesno
$MessageIcon_error = [System.Windows.MessageBoxImage]::Error
$MessageIcon_info = [System.Windows.MessageBoxImage]::Information
$MessageIcon_warning = [System.Windows.MessageBoxImage]::Warning
$Result1 = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType_yesno,$MessageIcon_warning)

sample code
if ($Result1 -eq 'yes') {
Write-Host "User click Yes or your custom code"
[System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon1)
}
Else {
Write-Host "User click No or your custom code"
}




more info - https://msdn.microsoft.com/en-us/libr...