PowerShell - 获取凭据解码密码?
我想在我的代码中使用 Get-Credential cmdlet。
如何轻松地从 System.Security.SecureString 格式解码回密码?
(我必须在代码的一部分使用明文格式的密码)
$credential = Get-Credential
$credential.Password | ConvertFrom-SecureString
$credential
#How to show password in text format?
我的解决方法,但我认为还有一种正常的方法
$credCachePS = New-Object System.Net.CredentialCache
$credCachePS.Add("uridummy", "NTLM", $credential)
$credCachePS | select Password
I want to use the Get-Credential cmdlet in my code.
How is is possible to decode the password easily back from the System.Security.SecureString format?
(I must use the password in clear text format at one part in my code)
$credential = Get-Credential
$credential.Password | ConvertFrom-SecureString
$credential
#How to show password in text format?
My workaround, but I think there is also a normal way
$credCachePS = New-Object System.Net.CredentialCache
$credCachePS.Add("uridummy", "NTLM", $credential)
$credCachePS | select Password
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我使用的(虽然这使它不安全,但我认为你明白):
This is what I use ( though this makes it insecure, but I think you understand that):