PowerShell Logo Small

Read-Host



This is the built-in help made by Microsoft for the command 'Read-Host', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' 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] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.Stringr>]] [<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 secure 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/p/?linkid=294000
Clear-Host
ConvertFrom-SecureString
Get-Host
Out-Host
Write-Host

REMARKS

<

Examples


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

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



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 --------------------------

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



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 the input. When the Enter key
is pressed, the value is stored as a SecureString object in the $pwd_secure_string variable.