PowerTip: Use PowerShell to Display Pop-Up Window

PowerTip: Use PowerShell to Display Pop-Up Window

  • Comments 7
  • Likes

Summary: Learn how to display a pop-up window by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display a pop-up window to a user when a script or function has completed?

Hey, Scripting Guy! Answer 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

$wshell.Popup("Operation Completed",0,"Done",0x1)

Note  For more information, see Popup Method.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • I will see your "MsgBox" and raise you an "InputBox":

    Add-Type -AssemblyName Microsoft.VisualBasic
    Microsoft.VisualBasic.Interaction]::MsgBox('Hello',1,'My MessageBox')
    Microsoft.VisualBasic.Interaction]::InputBox('Enter you name:', 'User Inforation','Joe Smith')

  • @jv

    Well 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...

  • @Dan Hayward
    It can be one line if you want (as your example shows).

  • Hello
    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


    Serguei Kouzmine

  • Thanks