On my last blog i mentioned about the Menu and now its time for a message box..
Tell me who wouldn’t love to see a message box when you do something successfully, give you a proof of completion also a satisfaction in a success scenario or opens you eye when you face an error.. Anything in a message box users now a days pay more attention.
below script will show you how to create a Message box GUI in powershell.
Function Show-Msgbox {
Param([string]$message=$(Throw "You must specify a message"),
[string]$button="okonly",
[string]$icon="information",
[string]$title="Message Box"
)
[reflection.assembly]::loadwithpartialname("microsoft.visualbasic") | Out-Null
[microsoft.visualbasic.interaction]::Msgbox($message,"$button,$icon",$title)
}
$rc=Show-Msgbox -message "Do you know what you're doing?" `
-icon "exclamation" -button "YesNoCancel" -title "Hey $env:username!!"
Switch ($rc) {
"Yes" {"Yes."}
"No" {"No."}
"cancel" {"Cancel"}
}
