Show a Popup Dialog From PowerShell

Display a native Windows message box with a title and buttons.

WindowsautomationpowershellproductivityLow risk
Run the snippet to open a message box; click OK to dismiss it.

01Command

Command
$ Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show("Hello from PowerShell","cmdcv")

02What it does

Loading System.Windows.Forms exposes the Win32 MessageBox API to PowerShell. The second argument is the title, and a third argument can choose buttons and an icon; the returned value tells you which button was clicked, so scripts can ask the user a question.

03Risk

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: Message boxes block until dismissed, so never call them in unattended or scheduled scripts.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • MessageBox Class
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Displays a message window to the user; Show returns the clicked button.

Last verified: 2026-09-20 · Category: System & Settings

06Related solutions