microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.3k stars 1.45k forks source link

Winget failing in Powershell 7.2.6 #2520

Open wstr-ncrum opened 2 years ago

wstr-ncrum commented 2 years ago

Winget works with default powershell instance using 5.1 on Windows 10 professional. After installing powershell 7 I attempted running any commands including winget --version and they all fail with the same message as shown below.

edit: only happening in Admin launched prompts

image

wstr-ncrum commented 2 years ago

Same terminal different version of powershell

image

denelon commented 2 years ago

I hate to ask, but did you try restarting the terminal and/or Windows? I'll try to reproduce this.

I just had PowerShell 5.1:

 denelon   ~    $PSVersionTable.PSVersion                                                   in pwsh at 08:28:43

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      25201  1000

I installed the latest version and restarted Windows Terminal:

PS C:\Users\denelon> $PSVersionTable.PSVersion

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      2      6

winget worked:

PS C:\Users\denelon> winget -v
v1.4.2161-preview
wstr-ncrum commented 2 years ago

I did do a restart. Did you run the version as administrator as well. That seems to be the thing for me. If I launch Windows terminal as admin and use powershell 7 it doesn't work