Is it possible to hide the user input from read-host in Powershell? Is it possible to hide the user input from read-host in Powershell? powershell powershell

Is it possible to hide the user input from read-host in Powershell?


You have to use the -AsSecureString switch but you can also retrieve the plaintext value:

$securedValue = Read-Host -AsSecureString$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securedValue)$value = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)