Get-Credentials fails to open a prompt for password on 1.15.2713 (Windows 11)
Windows Terminal version
1.15.2713.0
Windows build number
10.0.22621.0
Other Software
No response
Steps to reproduce
Open Terminal and type Get-Credential
Expected Behavior
Prompt for password to enter
Actual Behavior
Throws an error message:

Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.
At line:1 char:1
+ Microsoft.PowerShell.Security\Get-Credential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Credential], ParameterBindingException
+ FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.GetCredentialCommand
Works fine when using 1.16.2642.0 or using PowerShell 7. The difference being is that PowerShell 7 doesn't open outside window, and PowerShell 5.1 triggers an external window which is why there may be an issue.
Here's how it looks when working (in 1.16.2642.0)

Same here with 1.15.2713.0 in Windows 11 Pro.
If you open Out-GridView first then Get-Credential it works

Did you launch the Terminal by running PowerShell, causing a Terminal window to appear/? Or did you launch Terminal directly? I think there's another thread around here about how this is broken for the first terminal launch after a reboot...
Launch terminal with PowerShell - fails! Launch terminal by typing terminal - works!
But it doesn't matter whether this is just right after reboot or not.
Yup! Finally got a repro. Important step is to use defterm. So...
- open run
- type powershell.exe (opens in WT)
- type get-credential Error!
EDIT: Regardless of first launch
We currently have this issue with a script started with a "...\path\to\powershell.exe ...\path\to\script.ps1" shortcut.
In case anyone else needs this: The workaround we found was to prefix the command line in the shortcut with wt.exe, e.g. "wt.exe ...\path\to\powershell.exe ...\path\to\script.ps1".
The dotnet api for getting a process's main window iterates over all the top-level windows to find a top-level, visible window. The ConPTY tool window is not top-level (it has an owner). So this is something we actually can't fix on our side. It would require a dotnet foundation fix, which won't happen, because that's not really maintained anymore (in favor of dotnet core).
I'd lean towards closing this. @DHowett did more investigation here. ACK?
If you can't fix the underlying issue on your side, is it possible to at least improve the (misleading) error message?
E.g. instead of
Cannot process command because of one or more missing mandatory parameters: Credential.
it would be nice to have something like
Cannot open credentials window due to complex reasons outside our control. Please provide a
Credentialparameter or seehttps://github.com/microsoft/terminal/issues/14119for details and possible workarounds, if an interactive prompt is required.
Same here with 1.15.2713.0 in Windows 11 Pro.
If you open Out-GridView first then Get-Credential it works
Can confirm this is so far the only way I can open the credential prompt.
Also after that, you can open a new tab and even a new terminal window and Get-Credential works.
See https://github.com/microsoft/terminal/issues/11847#issuecomment-1402554766 for a workaround that gets PowerShell to prompt for the credential using the command line rather than through a credui window.
See #11847 (comment) for a workaround that gets PowerShell to prompt for the credential using the command line rather than through a credui window.
Or just run Out-GridView once.
After that Get-Credential works even after rebooting and cold start.
See #11847 (comment) for a workaround that gets PowerShell to prompt for the credential using the command line rather than through a credui window.
Or just run
Out-GridViewonce. After thatGet-Credentialworks even after rebooting and cold start.
Thanks, only don't understand what kind of sorcery this is! 😄
If you can't fix the underlying issue on your side, is it possible to at least improve the (misleading) error message?
E.g. instead of
Cannot process command because of one or more missing mandatory parameters: Credential.
it would be nice to have something like
Cannot open credentials window due to complex reasons outside our control. Please provide a
Credentialparameter or seehttps://github.com/microsoft/terminal/issues/14119for details and possible workarounds, if an interactive prompt is required.
There needs to be a sensible message, but yours is not entirely correct. If you don't add a password to the "Credential" parameter - you also need prompt and it still causes the same problem.
I'm not sure if the "Credential" being required parameter is an attempt to address the problems with prompt, but if it is - Microsoft failed to anticipate all the scenarios.
See #11847 (comment) for a workaround that gets PowerShell to prompt for the credential using the command line rather than through a credui window.
Or just run
Out-GridViewonce. After thatGet-Credentialworks even after rebooting and cold start.
What do you mean by that?
As soon as I close the GridView, the prompt stops being able to show up.
See #11847 (comment) for a workaround that gets PowerShell to prompt for the credential using the command line rather than through a credui window.
Or just run
Out-GridViewonce. After thatGet-Credentialworks even after rebooting and cold start.What do you mean by that?
As soon as I close the GridView, the prompt stops being able to show up.
Hi @GeorgievGG, really? That's odd.
I literally only had to enter Out-GridView once.
Also on a different device with Terminal version 1.12.10983.0 installed and Get-Credential works without workaround.
Edit: Tested it with Terminal version 1.17.230526001 and PowerShell version 5.1.22621.1778 > Works without workaround.
Edit 2: No more UI with PSVersion 7.3.4
I got stomped today by this issue and I'm still seeing it in version 1.17.11461.0 (which makes me wonder why this would have worked in 1.16).
I'm using something slightly different ($host.ui.PromptForCredential()) but it's basically the same thing.
So this really had me questioning my sanity.
But yes using 1.17 it wont show get-credential if running from existing terminal. in the script i am using i needed to use Start-Process wt -ArgumentList "powershell -File script_with_credential.ps1" to get it working
I had the same issue, restarted Powershell, and connected to AZ-Account again, and is working:
Looping back on this:
This is something we actually can't fix on our side. It would require a dotnet foundation fix, which won't happen, because that's not really maintained anymore (in favor of dotnet core).
Since this is kinda at an impasse blocked on this old version of dotnet, we're going to close this out on our side. Thanks everyone