How To Show Message Box in powerShell

Add-Type -AssemblyName System.Windows.Forms
# show the MsgBox:
$result = [System.Windows.Forms.MessageBox]::Show('you want to restart?
', 'Warning', 'YesNo', 'Warning')


The Add-Type statement loads the .NET assemblies required to display the message box. This statement is necessary only in a console window because a console PowerShell does not load graphical assemblies. Inside the ISE editor, you could get away with skipping Add-Type, just because the type System.Windows.Forms is loaded by the ISE editor by default.



if you use powershell command line then
Add-Type -AssemblyName System.Windows.Forms

must add on the top