golly, it just … popped up

It is easy to add a messagebox to powershell.  You can use ShowUI, but you can also simply create a com-object and make a Popup.

$a = new-object -comobject wscript.shell
$b = $a.popup(“This is a test”,10,”Test Message Box”,0)

This will have “this is a test” as the message with the “Test Message Box” title, disappear in 10 seconds (use 0 for forever), but does have a “OK” button to close immediately.

“0” is “OK”, “1” is “OK and Cancel”, and you can control the icon and get the button pushed as a return variable.

More options here.

A nice expansion of the messagebox, using a switch is here.

Powershell.com has a post that uses ‘Microsoft.VisualBasic’  assembly to accomplish the same task.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.