Get-WinGetPackage in 1.29.380 fails with "Failed to create instance: -2147023174" in an elevated PowerShell session

Ouverte
#6,560 13 commentaires 5 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
65/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
csharp, powershell
Domaine
backend, cli

Piste de recherche

The issue is in the PowerShell module Microsoft.WinGet.Client, specifically the Get-WinGetPackage command. Start by examining the COM interop code in the module that creates the instance, likely in the GetPackageCmdlet class. Compare the changes between versions 1.29.280 and 1.29.380 to identify what broke elevated session support. Test the fix in an elevated PowerShell session on Windows Server 2025 to confirm the error is resolved.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Issue-Bug PowerShell
Relevant area(s)

PowerShell Module

Relevant command(s)

Get-WinGetPackage. I did not test other commands, so those might be affected as well.

Brief description of your issue

Get-WinGetPackage in 1.29.380 fails with "Failed to create instance: -2147023174" in an elevated PowerShell session.

Steps to reproduce

In an elevated PowerShell session (tested with Windows Server 2025, the built-in Administrator account and the built-in PowerShell version):

Uninstall-Module Microsoft.WinGet.Client
Install-Module -Name Microsoft.WinGet.Client -RequiredVersion 1.29.280
Get-WinGetPackage

Note that Get-WinGetPackage outputs the list of installed packages. Now let's try the same with 1.29.380:

Uninstall-Module Microsoft.WinGet.Client
Install-Module -Name Microsoft.WinGet.Client -RequiredVersion 1.29.380
Get-WinGetPackage
Expected behavior

Get-WinGetPackage behaves like in 1.29.280.

Actual behavior
Get-WinGetPackage : Failed to create instance: -2147023174
At line:1 char:1
+ Get-WinGetPackage
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WinGetPackage], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.WinGet.Client.Commands.GetPackageC
   mdlet

Get-WinGetPackage works in a non-elevated PowerShell session.
Reverting to 1.29.280 (see above) fixes the issue.

Environment
Windows Package Manager v1.11.510
Windows: Windows.Server v10.0.26100.32522
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.26.510.0
Langage dominant
C++
Étoiles
26.6k
Forks
1.8k
Merge moyen
3 j 10 h
PR mergées (30 j)
41

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/winget-cli

Toutes les issues de microsoft/winget-cli

Issues similaires

Plus d'issues C++

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.