CmdID

CmdID / PowerShell / Cmdlets / Read

Read-Host

Reads a line of input from the console. PowerShell reference

From the PowerShell reference 2 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Reads a line of input from the console. The Read-Host cmdlet reads a line of input from the console (stdin). 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. NOTE: Read-Host has a limit of 8190 characters it can accept as input from a user.

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

Save console input to a variable

$Age = Read-Host "Please enter your age"Identify

Save console input as a secure string

$pwd_secure_string = Read-Host "Enter a Password" -AsSecureStringIdentify

Normalizing input

$prompt = @( 'List the cities you want weather information for.' 'When specifying multiple cities, separate them with a semi-colon, like:' "'New York; Osan; Koforidua'" ) -join ' ' $cities = Read-Host $prompt "Input cities string: nt'$cities'" $splitCities = $cities -split ';' "Split cities array:" $splitCities | ForEach-Object -Process { "t'$_'" } $normalizedCities = $splitCities | ForEach-Object -Process { $_.Trim() } "Normalized split cities array:" $normalizedCities | ForEach-Object -Process { "t'$_'" }Identify

Trips 2 Sigma rules: highHackTool - CrackMapExec PowerShell Obfuscation by Thomas Patzke; lowPotential Encoded PowerShell Patterns In CommandLine by Teymur Kheirkhabarov (idea), Vasiliy Burov (rule), oscd.community, Tim Shelton

Its page in the reference: Read-Host.

Parameters

2 in the PowerShell reference
-AsSecureStringIndicates that the cmdlet 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).
-PromptSpecifies the text of the prompt. Type a string. If the string includes spaces, enclose it in quotation marks. PowerShell appends a colon (:) to the text that you enter.