Would you like to learn how to prompt for user input using Powershell? In this tutorial, we are going to show you how to use Powershell to request input to your Powershell scripts on a computer running Windows.

• Windows 2012 R2
• Windows 2016
• Windows 2019
• Windows 10
• Windows 7

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Related tutorial - PowerShell

On this page, we offer quick access to a list of tutorials related to PowerShell.

Tutorial Powershell - Prompting for User Input

Start a Powershell command-line.

Start Powershell

Request a user input using Powershell.

Copy to Clipboard

Display the user input using Powershell.

Copy to Clipboard

In our example, the user input was stored in a variable named NAME.

Copy to Clipboard

Congratulations! You are able to request user input using Powershell.

Tutorial Powershell - Prompting for User input using a function

Start a Powershell command-line.

Start Powershell

Create a function to request the user input.

Copy to Clipboard

In our example, we created a function named REQUESTNAME to request the user input.

Call the function using Powershell.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

Congratulations! You are able to prompt a user for input using a Powershell function.

Tutorial Powershell - Prompting for User password

Start a Powershell command-line.

Start Powershell

Request a user input using Powershell.

Copy to Clipboard

Display the user input using Powershell.

Copy to Clipboard

In our example, the username was stored in a variable named MYUSERNAME.

In our example, the password was stored in a variable named MYPASS.

Copy to Clipboard

Congratulations! You are able to request passwords as input using Powershell.