Skip to content

Get-Credential Ability to Override Username #12222

@cpmcgrath

Description

@cpmcgrath

Summary of the new feature/enhancement

Back in Powershell 5, I could write a script which contained:

> $cred = Get-Credential -UserName "$first.$last"

A dialog would then appear, asking for the password, but it also gave the option of changing what the username was. This was useful as you could implement a naming standard, but when there was an edge case allowed the end user to be able to easily override it.

This workflow could be built into many scripts wanting to upgrade from Windows Powershell to Powershell 7.

Proposed technical implementation details (optional)

Reading #10625 I thought a -ConfirmUserName switch would be consistent, but a -DefaultUserName Username string would work just as well.

The below is how I saw it being used, being consistent with other command line tools

> $cred = Get-Credential -UserName "john.smith" -ConfirmUserName
> $cred = Get-Credential -DefaultUserName "john.smith"
PowerShell credential request
Enter your credentials.
User [john.smith]: 

The User can just press enter without typing anything and it will use the default value.

It would be nice if the value was presented as pre-typed - as this would allow the user to manipulate the value instead of either choose the default, or write it again from scratch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Securitysecurity related areas such as JEA

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions