Monday, April 2, 2012

Create a message box in powershell


Today I’d like to show how to create a message box in a very simple way:

What we need is some text, a title, the definition of our buttons and an icon for our window.

$text = "This is just a test"
$title = "Testbox"
$Buttons = [System.Windows.Forms.MessageBoxButtons]::OK
$Icon = [System.Windows.Forms.MessageBoxIcon]::Information

So now we got everything we need to pop this window up and we do it with this little command:

[System.Windows.Forms.MessageBox]::Show($text,$title,$Buttons,$Icon)

And that’s the result:


No comments:

Post a Comment