【问题标题】:PowerShell - Get-Credential decode password?PowerShell - 获取凭据解码密码?
【发布时间】:2011-09-15 15:11:35
【问题描述】:

我想在我的代码中使用 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

【问题讨论】:

    标签: powershell credentials system.security


    【解决方案1】:

    这是我使用的(虽然这使它不安全,但我想你明白这一点):

    $credential.GetNetworkCredential().password
    

    【讨论】:

      【解决方案2】:
      PS > $credential.GetNetworkCredential().username
      PS > $credential.GetNetworkCredential().password
      

      【讨论】:

        猜你喜欢
        • 2017-02-04
        • 1970-01-01
        • 2021-10-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-25
        • 1970-01-01
        相关资源
        最近更新 更多