PowerShell - Get-Credential decode password?

我怕爱的太早我们不能终老 提交于 2019-12-09 14:00:50

问题


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

回答1:


This is what I use ( though this makes it insecure, but I think you understand that):

$credential.GetNetworkCredential().password



回答2:


PS > $credential.GetNetworkCredential().username
PS > $credential.GetNetworkCredential().password


来源:https://stackoverflow.com/questions/7433178/powershell-get-credential-decode-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!