Get-Credential password confirmation
See original GitHub issueSummary of the new feature/enhancement
Passwords are hard. When we prompt for passwords, especially for complex passwords, it’s important to ensure that we know what we are entering. When using Get-Credential
interactively from the command line, you currently only get one opportunity to type in your password. It’s easy to fat finger a complex password. If you fat finger a complex password, then use it somewhere, you can make that resource inaccessible. We should enable a confirmation of the password when using this cmdlet interactively.
Proposed technical implementation details
Consider adding a -ConfirmPassword
parameter that confirms two password strings entered at the command line are correct. If correct, proceed with saving the credential. If incorrect, re-prompt the user for matching strings. Something like this:
Successful entry
PS C:\> Get-Credential -credential user1 -ConfirmPassword
PowerShell credential request
Enter your credentials.
Password for user user1: ************
Confirm password for user user1: ************
UserName Password
-------- --------
user1 System.Security.SecureString
Unsuccessful entry
PS C:\> Get-Credential -credential user1 -ConfirmPassword
PowerShell credential request
Enter your credentials.
Password for user user1: *****
Confirm password for user user1: ************
Passwords do not match.
Enter your credentials.
Password for user user1: ************
Confirm password for user user1: ************
UserName Password
-------- --------
user1 System.Security.SecureString
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:25 (3 by maintainers)
Search
public override PSCredential PromptForCredential
in https://github.com/PowerShell/PowerShell/blob/1be3f4cc0e465ae11ad8e59e9060f5a59e4762eb/src/Microsoft.PowerShell.Security/security/CredentialCommands.csYes, you should update tests in https://github.com/PowerShell/PowerShell/blob/acb52b3d9c92e347ea529242e8ab25a09ea31222/test/powershell/Modules/Microsoft.PowerShell.Security/GetCredential.Tests.ps1
It’s not a verification of the credential itself. It’s a confirmation that the password you entered twice matches. This would be similar to many web site credential creation procedures that are commonly seen, as well as the
passwd
command on Linux.