2
我正在尋找一種方法來隱藏來自Read-Host cmdlet的用戶輸入。是否可以在Powershell中隱藏讀主機的用戶輸入?
我知道我可以用-assecurestring來做到這一點,但我想將輸入保存爲純文本的變量。
有沒有可能的方法來做到這一點?
我正在尋找一種方法來隱藏來自Read-Host cmdlet的用戶輸入。是否可以在Powershell中隱藏讀主機的用戶輸入?
我知道我可以用-assecurestring來做到這一點,但我想將輸入保存爲純文本的變量。
有沒有可能的方法來做到這一點?
您必須使用-AsSecureString
開關,但你也可以檢索明文值:
$securedValue = Read-Host -AsSecureString
$bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securedValue)
$value = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)
http://stackoverflow.com/questions/15007104/how-can-i-use-powershells-read-主機功能,即表示接受-A-密碼換了,EXTERN –