get-credential does not work with powershell 5, works with powershell 7 #16007

Closed
opened 2026-01-31 04:54:42 +00:00 by claunia · 10 comments
Owner

Originally created by @HollisTech on GitHub (Nov 30, 2021).

Windows Terminal version

1.12.2931.0

Windows build number

22000.348 (win11)

Other Software

PSVersion 5.1.22000.282

Steps to reproduce

  1. Open WT preview.
  2. open psh 5 tab
  3. run get-credential
    output: Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.
    expected: gui or prompt.

Note

Expected Behavior

gui or prompt.

Note: behaves as expected with psh 7. Behaves as expected with WT release version (1.11.2921.0) and psh 5.

Actual Behavior

error output: Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.

Originally created by @HollisTech on GitHub (Nov 30, 2021). ### Windows Terminal version 1.12.2931.0 ### Windows build number 22000.348 (win11) ### Other Software PSVersion 5.1.22000.282 ### Steps to reproduce 1. Open WT preview. 2. open psh 5 tab 3. run get-credential output: Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential. expected: gui or prompt. Note ### Expected Behavior gui or prompt. Note: behaves as expected with psh 7. Behaves as expected with WT release version (1.11.2921.0) and psh 5. ### Actual Behavior error output: Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.
claunia added the Resolution-Duplicate label 2026-01-31 04:54:42 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 30, 2021):

This looks like you're describing #2988. PowerShell 7 (very correctly) prompts for the credential at the actual commandline. PowerShell 5, however, pops open another window to get the credentials. In the Terminal (and anything using ConPTY), that external window is going to appear somewhere randomly in the z-order, which includes underneath the terminal window.

/dup #2988

@zadjii-msft commented on GitHub (Nov 30, 2021): This looks like you're describing #2988. PowerShell 7 (very correctly) prompts for the credential at the actual commandline. PowerShell 5, however, pops open another window to get the credentials. In the Terminal (and anything using ConPTY), that external window is going to appear somewhere randomly in the z-order, which includes _underneath the terminal window_. /dup #2988
Author
Owner

@ghost commented on GitHub (Nov 30, 2021):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Nov 30, 2021): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@HollisTech commented on GitHub (Nov 30, 2021):

This is not a dupe. Note the error message. There is no attempt to open the gui option for get-credential.

@HollisTech commented on GitHub (Nov 30, 2021): This is *not* a dupe. Note the error message. There is no attempt to open the gui option for get-credential.
Author
Owner

@DHowett commented on GitHub (Nov 30, 2021):

It looks like PowerShell 5 opens a window to populate the Credential parameter. That window appears to be immediately dismissed -- possibly by other software running on your computer (?). This results in the reported error message.

The unfortunate thing is... once PowerShell pops up that window, whether it is in front of or behind the Terminal, the Terminal's no longer part of the picture.
It can pop up that window in all normal system configurations (even if it shows up behind!)

The best place for this discussion is probably the powershell repository, but given that the issue is fixed in PS7 they're not likely to book work to fix 5.x. ☹️

@DHowett commented on GitHub (Nov 30, 2021): It looks like PowerShell 5 opens a window to populate the Credential parameter. That window appears to be immediately dismissed -- possibly by other software running on your computer (?). This results in the reported error message. The unfortunate thing is... once PowerShell pops up that window, whether it is _in front of_ or _behind_ the Terminal, the Terminal's no longer part of the picture. It can pop up that window in all normal system configurations (even if it shows up behind!) The best place for this discussion is probably [the powershell repository](https://github.com/powershell/powershell), but given that the issue is fixed in PS7 they're not likely to book work to fix 5.x. ☹️
Author
Owner

@WolfgangHG commented on GitHub (Dec 29, 2022):

@HollisTech did you create any followup issue? For me, this happens with Win11 22H2 and Terminal 1.15.3466.0

I can work around it by opening a second powershell tab in terminal:
terminal

Also, it does not happen if I start powershell from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe".

@WolfgangHG commented on GitHub (Dec 29, 2022): @HollisTech did you create any followup issue? For me, this happens with Win11 22H2 and Terminal 1.15.3466.0 I can work around it by opening a second powershell tab in terminal: ![terminal](https://user-images.githubusercontent.com/138049/209950369-6999889c-e6c3-4846-b02d-004b695853e4.png) Also, it does not happen if I start powershell from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe".
Author
Owner

@jborean93 commented on GitHub (Jan 24, 2023):

The problem here is that Windows PowerShell is calling CredUIPromptForCredentialsW with a hwndParent in the CREDUI_INFO structure as the parent process' window handle. In the failure case I believe the parent process ends up being explorer.exe and not Windows Terminal and something inside CredUIPromptForCredentialsW ultimately leads to that failure. A workaround is to set the following registry key that forces Windows PowerShell to use the console to prompt the user just like it does in PowerShell 7.

Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds" -Name "ConsolePrompting" -Value $True

You can remove that property or set it to $false to revert back to the original behaviour.

@jborean93 commented on GitHub (Jan 24, 2023): The problem here is that Windows PowerShell is calling [CredUIPromptForCredentialsW](https://learn.microsoft.com/en-us/windows/win32/api/wincred/nf-wincred-creduipromptforcredentialsw) with a `hwndParent` in the [CREDUI_INFO](https://learn.microsoft.com/en-us/windows/win32/api/wincred/ns-wincred-credui_infow) structure as the parent process' window handle. In the failure case I believe the parent process ends up being `explorer.exe` and not Windows Terminal and something inside `CredUIPromptForCredentialsW` ultimately leads to that failure. A workaround is to set the following registry key that forces Windows PowerShell to use the console to prompt the user just like it does in PowerShell 7. ```powershell Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds" -Name "ConsolePrompting" -Value $True ``` You can remove that property or set it to `$false` to revert back to the original behaviour.
Author
Owner

@vaidya1s commented on GitHub (Jan 30, 2023):

jborean93

It works,Thanks.

@vaidya1s commented on GitHub (Jan 30, 2023): > [jborean93](/jborean93) It works,Thanks.
Author
Owner

@aarontguilmette commented on GitHub (Mar 28, 2023):

@HollisTech did you create any followup issue? For me, this happens with Win11 22H2 and Terminal 1.15.3466.0

I can work around it by opening a second powershell tab in terminal: terminal

Also, it does not happen if I start powershell from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe".

Can confirm, this is still an issue with PS 5.1 on Windows 11. The "open a new tab in the PS console" trick works, as does the Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds" -Name "ConsolePrompting" -Value $True suggestion from @jborean93

PS C:\Users\AaronGuilmette> $PSVersionTable

Name Value


PSVersion 5.1.22621.963
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.963
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

@aarontguilmette commented on GitHub (Mar 28, 2023): > @HollisTech did you create any followup issue? For me, this happens with Win11 22H2 and Terminal 1.15.3466.0 > > I can work around it by opening a second powershell tab in terminal: ![terminal](https://user-images.githubusercontent.com/138049/209950369-6999889c-e6c3-4846-b02d-004b695853e4.png) > > Also, it does not happen if I start powershell from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe". Can confirm, this is still an issue with PS 5.1 on Windows 11. The "open a new tab in the PS console" trick works, as does the `Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds" -Name "ConsolePrompting" -Value $True` suggestion from @jborean93 PS C:\Users\AaronGuilmette> $PSVersionTable Name Value ---- ----- PSVersion 5.1.22621.963 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.963 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Author
Owner

@jeroenebus commented on GitHub (Apr 20, 2023):

@HollisTech did you create any followup issue? For me, this happens with Win11 22H2 and Terminal 1.15.3466.0
I can work around it by opening a second powershell tab in terminal: terminal
Also, it does not happen if I start powershell from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe".

Can confirm, this is still an issue with PS 5.1 on Windows 11. The "open a new tab in the PS console" trick works, as does the Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds" -Name "ConsolePrompting" -Value $True suggestion from @jborean93

PS C:\Users\AaronGuilmette> $PSVersionTable

Name Value

PSVersion 5.1.22621.963 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.963 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Same here, workaround to open a new terminal tab works for me!

@jeroenebus commented on GitHub (Apr 20, 2023): > > @HollisTech did you create any followup issue? For me, this happens with Win11 22H2 and Terminal 1.15.3466.0 > > I can work around it by opening a second powershell tab in terminal: ![terminal](https://user-images.githubusercontent.com/138049/209950369-6999889c-e6c3-4846-b02d-004b695853e4.png) > > Also, it does not happen if I start powershell from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe". > > Can confirm, this is still an issue with PS 5.1 on Windows 11. The "open a new tab in the PS console" trick works, as does the `Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds" -Name "ConsolePrompting" -Value $True` suggestion from @jborean93 > > PS C:\Users\AaronGuilmette> $PSVersionTable > > Name Value > > PSVersion 5.1.22621.963 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.963 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 Same here, workaround to open a new terminal tab works for me!
Author
Owner

@WolfgangHG commented on GitHub (Apr 20, 2023):

See #14119 - still open, so there is hope. A partial fix might be in 1.17

@WolfgangHG commented on GitHub (Apr 20, 2023): See #14119 - still open, so there is hope. A partial fix might be in 1.17
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16007