read-host
reads a line of input. read-host
is used to assign a text that is entered by a user to a variable: $val = read-host write-output $val
-prompt
, the user is shown a text after which the value can be entered: $val = read-host -prompt 'Please enter a value'
-prompt
is the first parameter of read-host
, the string -prompt
can also be left out. -asSecureString
, the entered value is masked with asterisks and read-host
returns a System.Security.SecureString
: PS C:\> $sec = read-host -prompt 'Password' -asSecureString Password: ****** PS C:\> $sec System.Security.SecureString PS C:\> convertFrom-secureString $sec 01000000d08c9ddf0115d1118…