开发者

PowerShell - Get-Credential decode password?

开发者 https://www.devze.com 2023-04-04 22:34 出处:网络
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 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

$credC开发者_运维问答achePS = New-Object System.Net.CredentialCache 
$credCachePS.Add("uridummy", "NTLM", $credential) 
$credCachePS | select Password


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

$credential.GetNetworkCredential().password


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

精彩评论

暂无评论...
验证码 换一张
取 消