Keep the graphical input prompt or avoid a GUI display: How to decide

How can I show a graphical input prompt in PowerShell?

Requires Free Membership to View

First, ask yourself if that's what you really want to do.

PowerShell itself is designed to be hosted inside of many different hosting applications. The PowerShell.exe interface you may be used to; the Console host is one such host. The PowerShell ISE is another. But there are more, including the Wsmprovhost.exe that's used to host PowerShell when you use remoting to connect to a remote computer.

Different hosts have different capabilities, and some of them run in different contexts. For example, Wsmprovhost.exe isn't something you'll ever see or interact with directly; it runs on a remote computer, receives your commands, executes those commands and transmits results back to you. Popping up a graphical dialog box within that host won't work, because there's nobody to see it.

PowerShell scripts remain portable when you don't use GUI displays. Instead, use Read-Host. Some hosts will implement that as a command-line input prompt; others may implement it as a graphical dialog. The host application decides, based on its context and usage environment.

If you need to pop up a graphical input box, you can. You just have to access the .NET Framework:

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null

$computer = [Microsoft.VisualBasic.Interaction]::InputBox("Enter a computer name", "Computer", "$env:computername")

That example even shows you how to prefill a default value for the input prompt. Give it a try. It doesn't do anything dangerous, and it'll let you see how the InputBox function works.

Understand that the graphical input box isn't a PowerShell thing -- it's "borrowing" from .NET's VisualBasic code.

About the author
Don Jones is a well-known and respected PowerShell expert and educator. He's co-author of three books on PowerShell (see for a list). You can find his content online, including his PowerShell Q&A forums, by visiting

This was first published in August 2013

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: