严重性级别:错误
DESCRIPTION
通过命令使用 AsPlainText 参数 ConvertTo-SecureString 可以公开安全信息。
方式
使用标准加密变量执行任何 SecureString 转换。
建议
如果需要从某个位置检索密码而不提示用户,请考虑使用 PowerShell 库中的 SecretStore 模块。
示例:
错
$UserInput = Read-Host 'Please enter your secure code'
$EncryptedInput = ConvertTo-SecureString -String $UserInput -AsPlainText -Force
正确
$SecureUserInput = Read-Host 'Please enter your secure code' -AsSecureString