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

未關閉
#6,560 13 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
65/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
csharp, powershell
領域
backend, cli

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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
主要語言
C++
星號
26.6k
分支
1.8k
平均合併
3 天 10 小時
30 天內合併 PR
41

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/winget-cli 的其他 Issue

查看 microsoft/winget-cli 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。