Prompting for Credentials in Console

by May 26, 2020

When you run Get-Credential or are otherwise prompted for a username and password, Windows PowerShell (powershell.exe) always opens a separate credentials dialog. The new PowerShell 7 (pwsh.exe) prompts inside the console:

PS> Get-Credential 

PowerShell credential request
Enter your credentials.
User: Tobias
Password for user Tobias: ******

UserName                     Password
--------                     --------
Tobias   System.Security.SecureString    

If you like the console prompt better than opening separate dialogs, you can switch the default behavior for Windows PowerShell. You do need Administrator privileges though to change the registry setting:

$key = "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds"
Set-ItemProperty -Path $key -Name ConsolePrompting -Value $true

To restore the default behavior, either change the value to $false, or remove the registry value via Remove-ItemProperty.

Twitter This Tip! ReTweet this Tip!