Learn about Windows PowerShell
Summary: Learn how to display a pop-up window by using Windows PowerShell.
How can I use Windows PowerShell to display a pop-up window to a user when a script or function has completed?
There are several ways to display a pop-up window, but the following command doesn’t require loading assemblies prior to creating the window:
$wshell = New-Object -ComObject Wscript.Shell
Note For more information, see Popup Method.
I will see your "MsgBox" and raise you an "InputBox":Add-Type -AssemblyName Microsoft.VisualBasicMicrosoft.VisualBasic.Interaction]::MsgBox('Hello',1,'My MessageBox')Microsoft.VisualBasic.Interaction]::InputBox('Enter you name:', 'User Inforation','Joe Smith')
@jvWell played! That is definitely another type of *box that is available to use.
If anyone uses jv's examples, be sure to add the left square bracket [ to the beginning of the last two lines.
Why two lines?
(new-object -ComObject wscript.shell).Popup("Operation Completed",0,"Done",0x1)
If you want to remove the "Cancel" button, remove the ",0x1" at the end...
It can be one line if you want (as your example shows).
Please check my article at codeproject for extensive coverage of using Windows Forms and WPF with Powershell for typical Powershell tasks which often require various option prompts.
You find there over 30 common Windows form patterns ( grids, check/radio boxes, treeviews, tabbed dialogs, itemlists, passwords, tooltips, system tray, XAML polygons, pinvoke, hosting custom controls, dealing with selenium webdriver-unfriendly dialogs etc.
) all covered there - working code for every example is provided.
The samples provided in the article are hopefully easily tailored to any purpose the reader finds them fit.
Routine daily devops tasks of executing Powershell scripts in a complex environment suddenly become a less challenging task