terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Get-Credentials fails to open a prompt for password on 1.15.2713 (Windows 11)

Open PrzemyslawKlys opened this issue 3 years ago • 4 comments

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:

image

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)

image image

PrzemyslawKlys avatar Oct 02 '22 21:10 PrzemyslawKlys

Same here with 1.15.2713.0 in Windows 11 Pro.

If you open Out-GridView first then Get-Credential it works

image

mruncleleon avatar Oct 04 '22 12:10 mruncleleon

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...

zadjii-msft avatar Oct 05 '22 01:10 zadjii-msft

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.

PrzemyslawKlys avatar Oct 05 '22 07:10 PrzemyslawKlys

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

carlos-zamora avatar Oct 05 '22 20:10 carlos-zamora

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".

HeinziAT avatar Mar 22 '23 08:03 HeinziAT

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?

zadjii-msft avatar Apr 12 '23 22:04 zadjii-msft

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 Credential parameter or see https://github.com/microsoft/terminal/issues/14119 for details and possible workarounds, if an interactive prompt is required.

HeinziAT avatar Apr 13 '23 08:04 HeinziAT

Same here with 1.15.2713.0 in Windows 11 Pro.

If you open Out-GridView first then Get-Credential it works

image

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.

Varusal avatar Apr 14 '23 18:04 Varusal

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.

jborean93 avatar Apr 20 '23 18:04 jborean93

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.

Varusal avatar Apr 22 '23 15:04 Varusal

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.

Thanks, only don't understand what kind of sorcery this is! 😄

jeroenebus avatar Apr 22 '23 19:04 jeroenebus

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 Credential parameter or see https://github.com/microsoft/terminal/issues/14119 for 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.

GeorgievGG avatar May 22 '23 17:05 GeorgievGG

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.

What do you mean by that?

As soon as I close the GridView, the prompt stops being able to show up.

GeorgievGG avatar May 22 '23 17:05 GeorgievGG

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.

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 image

Varusal avatar Jun 04 '23 15:06 Varusal

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.

skrysm avatar Jun 12 '23 11:06 skrysm

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

robmarkoski avatar Jul 13 '23 01:07 robmarkoski

I had the same issue, restarted Powershell, and connected to AZ-Account again, and is working:

image

GUREYESO avatar Sep 21 '23 12:09 GUREYESO

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

zadjii-msft avatar Oct 04 '23 21:10 zadjii-msft