Read-Host - PowerShell command help and examples

Reads a line of input from the console. (Read-Host)


NAME
Read-Host
SYNOPSIS
Reads a line of input from the console.
SYNTAX
Read-Host [[-Prompt] <Object>] [-AsSecureString] [<CommonParameters>]
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.
PARAMETERS
-AsSecureString [<SwitchParameter>] Displays asterisks (*) in place of the characters that the user types as input. When you use this parameter, the output of the Read-Host cmdlet is a SecureString object (System.Security.SecureString). Required? false Position? named Default value Accept pipeline input? false Accept wildcard characters? false -Prompt <Object> Specifies the text of the prompt. Type a string. If the string includes spaces, enclose it in quotation marks. For example, "Type an integer: ". Required? false Position? 1 Default value Accept pipeline input? false Accept wildcard characters? false <CommonParameters> This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters".
INPUTS
None You cannot pipe input to this cmdlet.
OUTPUTS
System.String or System.Security.SecureString If the AsSecureString parameter is used, Read-Host returns a SecureString. Otherwise, it returns a string.
NOTES

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 the input. When the Enter key is pressed, the value is stored as a SecureString object in the $pwd_secure_string variable. RELATED LINKS Online version: http://go.microsoft.com/fwlink/?LinkID=113371 Get-Host Out-Host Write-Host ConvertFrom-SecureString C:\Windows>powershell get-help Set-Alias -full

Microsoft Windows [Version 10.0.19045.3693]
Copyright (c) 2023 Microsoft Corporation.

ColorConsole [Version 3.7.1000] PowerShell 2.0-Export

Windows 11, 10, 8.1, 8, 7 / Server 2022, 2019, 2016











Windows-10


... Windows 10 FAQ
... Windows 10 How To


Windows 10 How To


... Windows 11 How To
... Windows 10 FAQ



PowerShell: Reads a line of input from the console.

HTTP: ... PS_Windows/en/Read-Host.htm
0.077
12125
Open the Experience Index files directory or start recalculation of the performance index!
Die meisten Viren sind mutiert, einige haben noch die typische Corona Form!
Win Ping - komfortables Pingen für Windows 11, 10,  ... Desktop und Server OS
The Scan to PDF Tool for MS Windows 11, 10, ... and Server OS!
To convert scanned page to PDF A4, A3, A2, A1 on Windows 11, 10, 8.1, ...!
Auslesen / Neuberechnen des Leistungs Indexes unter Windows 11, 10 ..!
Fonts printing with print and preview function!
Permanently disable Windows 10 Defender!
Download Chromium Edge offline installer!
Copying a website address to a desktop computer?



(0)