Hello,
Hereunder a nice way to create simple messagebox with PowerShell :
[reflection.assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null [System.Windows.Forms.Application]::EnableVisualStyles() [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 :
[Enum]::GetNames([System.Windows.Forms.MessageBoxIcon]) [Enum]::GetNames([System.Windows.Forms.MessageBoxButtons])
Pingback: Create Input Box PowerShell - It for DummiesIt for Dummies