Create MessageBox easily with PowerShell


Hereunder a nice way to create simple messagebox with PowerShell :

[reflection.assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Windows.Forms.MessageBox]::Show("Would you like a MessageBox popup ?","This is a question !", "YesNoCancel”


This uses a .Net method :


You can do a lot of different kinds of messagebox :

[System.Windows.Forms.MessageBox]::Show("Would you like a MessageBox popup ?","This is a warning !", "AbortRetryIgnore” , "Warning”)


[System.Windows.Forms.MessageBox]::Show("Would you like a MessageBox popup ?","This is an error !", "Ok” , "Error”)


When you click on a button, the button value is returned to PowerShell, so, you can take different action depending of the clicked button :


You can list the possible windows types and the possible buttons with those enum :



One thought on “Create MessageBox easily with PowerShell

  1. Pingback: Create Input Box PowerShell - It for DummiesIt for Dummies

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.