PowerTip: Use PowerShell to Display Pop-Up Window

PowerTip: Use PowerShell to Display Pop-Up Window

  • Comments 15
  • 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).

  • Thanks

  • Great post! Was wondering if anyone had any idea if you wanted to insert the local computer name in the pop up window.

    somethink like:
    $wshell.Popup("Welcome $ComputerName Your network drives are mounted",0,"Mappning")

    And also if you could make it Time-based so that the user didnt have to push OK or cancel button. So it would dissapear in 5 sec or so.

    Thanks in advance.

  • Hi Kurt,

    $wshell.Popup("Welcome $Env:ComputerName Your network drives are mounted",5,"Mappning")

  • Is there any way to link applications based on java to powershell..?

  • This is a test

  • Can you send messages to other people on the same network?

  • Can a custom image be included in to a pop up? Like say a logo

  • [System.Windows.Forms.MessageBox]::Show("Title" , "Content")

  • How do you create the popup box with only message and no buttons (or buttons grayed out along with X button)?

  • how about including a textbox?