PowerShell-Get-Credential解码密码? [英] PowerShell - Get-Credential decode password?

查看:290
本文介绍了PowerShell-Get-Credential解码密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在代码中使用Get-Credential cmdlet。

I want to use the Get-Credential cmdlet in my code.

如何从System.Security.SecureString格式轻松解密密码?

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


推荐答案

这就是我使用的(尽管这使得它不安全,但是我想您理解):

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

$credential.GetNetworkCredential().password

这篇关于PowerShell-Get-Credential解码密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆