Create PSCredential without a password

后端 未结 2 504
悲哀的现实
悲哀的现实 2020-12-18 17:59

How to create a instance of PSCredential that has no password? (Without manually filling out a Get-Credential dialog with no password, this is for unattended ru

相关标签:
2条回答
  • 2020-12-18 18:36

    Solution:

    $mycreds = New-Object System.Management.Automation.PSCredential 
                  ("username", (new-object System.Security.SecureString))
    
    0 讨论(0)
  • 2020-12-18 18:40

    Use the Get-Credential cmdlet, when the credential dialog appears, don't type a password

    $cred = Get-Credential pebrian27
    $cred.GetNetworkCredential() | select UserName,Password
    
    UserName   Password
    --------   --------
    pebrian27
    
    0 讨论(0)
提交回复
热议问题