Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Read-Host

Read-Host - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Read a line of input from the host console


-prompt Object
       The string that will become the prompt object. If the prompt 
       string includes spaces, it must be surrounded by quotes.
       If set to true, the input will be echoed as star characters (*). 
       The output will then be a Securestring object.

      -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Present the string "Please enter your name:" as a prompt. When a value is entered and the Enter key is pressed, that value is stored in the $myname variable:

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

Presents the string "Enter a Password:" as a prompt. When a password is entered and the Enter key is pressed, the value is stored as a SecureString:

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