1

Consider the following example:

Read-Host "Enter a value"

While this works fine, every time the user hits enter after entering a value, the same value is echoed on the next line. This is driving me nuts. There must be a way of remove this stupid echo?

Nkosi
  • 235,767
  • 35
  • 427
  • 472
pmdci
  • 270
  • 5
  • 23

2 Answers2

3

Pass the entered value into a variable

$value = Read-Host "Enter a value"

unless I pass the variable back out to host like in the following example

$value = Read-Host "Enter a value"
$value

it won't be echoed.

Nkosi
  • 235,767
  • 35
  • 427
  • 472
1

In PowerShell Core, you need to use -MaskInput as in:

$pwd_string = Read-Host "Enter a Password" -MaskInput

Read-Host reference

Frank Monroe
  • 1,557
  • 2
  • 13
  • 20