PowerShell Logo Small

Read-Host



This is the built-in help made by Microsoft for the command 'Read-Host', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Reads a line of input from the console.

SYNTAX


Read-Host [[-Prompt] <Object>] [-AsSecureString] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Read-Host cmdlet reads a line of input from the console. You can use it to prompt a user for input. Because you can save the input as a secur
e string, you can use this cmdlet to prompt users for secure data, such as passwords, as well as shared data.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113371
Get-Host
Out-Host
Write-Host
ConvertFrom-SecureString

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>$age = read-host "Please enter your age:"



Description
-----------
This command displays the string "Please enter your age:" as a prompt. When a value is entered and the Enter key is pressed, the value is stored
in the $age variable.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>$pwd_secure_string = read-host "Enter a Password:" -assecurestring



Description
-----------
This command displays the string "Enter a Password:" as a prompt. As a value is being entered, asterisks (*) appear on the console in place of th
e input. When the Enter key is pressed, the value is stored as a SecureString object in the $pwd_secure_string variable.