winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Powershell cmdlets fail with generic message

Open luis-aranda opened this issue 2 years ago • 2 comments
trafficstars

Brief description of your issue

I recently updated my winget version to 1.4.11071 and installed the PowerShell module via PSGallery. Almost all of the cmdlets fail to run with the message "Exception has been thrown by the target of an invocation."

Steps to reproduce

PS>Import-Module -Name Microsoft.WinGet.Client -Verbose VERBOSE: Loading module from path 'C:\Users\luis\Documents\PowerShell\Modules\Microsoft.WinGet.Client\0.2.1\Microsoft.WinGet.Client.psd1'. VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\luis\Documents\PowerShell\Modules\Microsoft.WinGet.Client\0.2.1\Format.ps1xml'. VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client. VERBOSE: Loading module from path 'C:\Users\luis\Documents\PowerShell\Modules\Microsoft.WinGet.Client\0.2.1\runtimes\win10-x64\lib\net6.0-windows10.0.22000.0\Microsoft.WinGet.Client.Cmdlets.dll'. VERBOSE: Importing cmdlet 'Assert-WinGetPackageManager'. VERBOSE: Importing cmdlet 'Find-WinGetPackage'. VERBOSE: Importing cmdlet 'Get-WinGetPackage'. VERBOSE: Importing cmdlet 'Get-WinGetSource'. VERBOSE: Importing cmdlet 'Get-WinGetUserSettings'. VERBOSE: Importing cmdlet 'Get-WinGetVersion'. VERBOSE: Importing cmdlet 'Install-WinGetPackage'. VERBOSE: Importing cmdlet 'Repair-WinGetPackageManager'. VERBOSE: Importing cmdlet 'Set-WinGetUserSettings'. VERBOSE: Importing cmdlet 'Test-WinGetUserSettings'. VERBOSE: Importing cmdlet 'Uninstall-WinGetPackage'. VERBOSE: Importing cmdlet 'Update-WinGetPackage'. VERBOSE: Loading module from path 'C:\Users\luis\Documents\PowerShell\Modules\Microsoft.WinGet.Client\0.2.1\Microsoft.WinGet.Client.psm1'. VERBOSE: Exporting function 'Enable-WinGetSetting'. VERBOSE: Exporting function 'Disable-WinGetSetting'. VERBOSE: Exporting function 'Get-WinGetSettings'. VERBOSE: Exporting function 'Add-WinGetSource'. VERBOSE: Exporting function 'Remove-WinGetSource'. VERBOSE: Exporting function 'Reset-WinGetSource'. VERBOSE: Exporting cmdlet 'Assert-WinGetPackageManager'. VERBOSE: Exporting cmdlet 'Find-WinGetPackage'. VERBOSE: Exporting cmdlet 'Get-WinGetPackage'. VERBOSE: Exporting cmdlet 'Get-WinGetSource'. VERBOSE: Exporting cmdlet 'Get-WinGetUserSettings'. VERBOSE: Exporting cmdlet 'Get-WinGetVersion'. VERBOSE: Exporting cmdlet 'Install-WinGetPackage'. VERBOSE: Exporting cmdlet 'Repair-WinGetPackageManager'. VERBOSE: Exporting cmdlet 'Set-WinGetUserSettings'. VERBOSE: Exporting cmdlet 'Test-WinGetUserSettings'. VERBOSE: Exporting cmdlet 'Uninstall-WinGetPackage'. VERBOSE: Exporting cmdlet 'Update-WinGetPackage'. VERBOSE: Importing cmdlet 'Assert-WinGetPackageManager'. VERBOSE: Importing cmdlet 'Find-WinGetPackage'. VERBOSE: Importing cmdlet 'Get-WinGetPackage'. VERBOSE: Importing cmdlet 'Get-WinGetSource'. VERBOSE: Importing cmdlet 'Get-WinGetUserSettings'. VERBOSE: Importing cmdlet 'Get-WinGetVersion'. VERBOSE: Importing cmdlet 'Install-WinGetPackage'. VERBOSE: Importing cmdlet 'Repair-WinGetPackageManager'. VERBOSE: Importing cmdlet 'Set-WinGetUserSettings'. VERBOSE: Importing cmdlet 'Test-WinGetUserSettings'. VERBOSE: Importing cmdlet 'Uninstall-WinGetPackage'. VERBOSE: Importing cmdlet 'Update-WinGetPackage'. VERBOSE: Importing function 'Add-WinGetSource'. VERBOSE: Importing function 'Disable-WinGetSetting'. VERBOSE: Importing function 'Enable-WinGetSetting'. VERBOSE: Importing function 'Get-WinGetSettings'. VERBOSE: Importing function 'Remove-WinGetSource'. VERBOSE: Importing function 'Reset-WinGetSource'.

PS>Find-WinGetPackage -Query quicklook -Verbose -Debug

TerminatingError(Find-WinGetPackage): "Exception has been thrown by the target of an invocation." Find-WinGetPackage: Exception has been thrown by the target of an invocation. Find-WinGetPackage: Exception has been thrown by the target of an invocation.

PS> Get-WinGetPackage

TerminatingError(Get-WinGetPackage): "Exception has been thrown by the target of an invocation.

Expected behavior

Find the package searched via Find-WinGetPackage and get the list of packages with Get-WinGetPackage

Actual behavior

Most of the cmdlets are failing with error a terminating error "Exception has been thrown by the target of an invocation."

Environment

Windows Package Manager v1.4.11071
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.1702
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.19.11071.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

Links               
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.3
PSEdition                      Core
GitCommitId                    7.4.0-preview.3
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

luis-aranda avatar Jun 01 '23 03:06 luis-aranda

Is there some resolution to this? I am facing exactly the same issue for some time now too. WinGet works, but PowerShell integration does not.

oldium avatar Apr 28 '24 07:04 oldium

Uninstalling and reinstalling PowerShell (I am using version from Microsoft Store) helped me to fix the issue.

oldium avatar Apr 28 '24 07:04 oldium

The PowerShell cmdlets do not work yet on MSIX build of PowerShell (typically installed from MS Store, see https://github.com/microsoft/winget-cli/issues/3805). Can you try upgrading to the latest version of powershell module, install the MSI build of PowerShell (either from their GitHub releases or WinGet) and then try running the cmdlets?

mdanish-kh avatar May 06 '24 19:05 mdanish-kh

I can confirm that resolves the issue. Thanks @mdanish-kh.

luis-aranda avatar May 06 '24 20:05 luis-aranda

Glad you got it working! I'll close this as duplicate of the other issue for better tracking

Duplicate of #3805

mdanish-kh avatar May 07 '24 20:05 mdanish-kh

Hello @luis-aranda,

We've identified this as a duplicate of another issue or PR that already exists. This specific instance is being closed in favor of the linked issue. Please add your 👍 to the other issue to raise its priority. Thanks for your contribution!

Template: msftbot/duplicate/closed