Skip to content

Repair-WinGetPackageManager -Latest fails on the new PowerShell module v1.12.350 #5826

@AmirTerani

Description

@AmirTerani

Relevant area(s)

PowerShell Module

Relevant command(s)

Repair-WinGetPackageManager

Brief description of your issue

After the new version 1.12.350 of the PowerShell module was released, our Autopilot script began failing. This script installs the latest version of the module and then runs the
Repair-WinGetPackageManager -Latest -Verbose -Force
command to set up WinGet and its prerequisites. Once the update rolled out, the process started failing with the following error:

PS C:\>Repair-WinGetPackageManager -Latest -Verbose -Force
VERBOSE: Creating MTA thread
VERBOSE: Running winget.exe with --version
Repair-WinGetPackageManager : Could not find Windows Runtime type 'Microsoft.Management.Deployment.PackageManager'.
At line:1 char:1
+ Repair-WinGetPackageManager -Latest -Verbose -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Repair-WinGetPackageManager], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.WinGet.Client.Commands.RepairWinGetPackageManagerCmdl
   et

Steps to reproduce

This happened on Windows 11 25H2 10.0.26200.6899 devices but I was able to reproduce it even on a 23H2 Windows Sandbox:

PS C:\Users\WDAGUtilityAccount> Set-ExecutionPolicy Bypass -Force                                                       
PS C:\Users\WDAGUtilityAccount> install-module microsoft.winget.client                                                  
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\WDAGUtilityAccount\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet   
to install and import the NuGet provider now?                                                                           
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y                                                                                                                                                                                      Untrusted repository                                                                                                    
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?                                                                                                            
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A   

PS C:\Users\WDAGUtilityAccount> Repair-WinGetPackageManager -Latest -Verbose -Force                                     VERBOSE: Creating MTA thread                                                                                            
VERBOSE: Running winget.exe with --version                                                                              
VERBOSE: 'winget.exe' Win32Exception The system cannot find the file specified                                          VERBOSE: Executing Appx cmdlet Get-AppxPackage -Name Microsoft.DesktopAppInstaller                                      VERBOSE: Integrity category type: AppInstallerNotInstalled                                                              
VERBOSE: Downloading https://github.com/microsoft/winget-cli/releases/download/v1.11.510/DesktopAppInstaller_Dependencies.json               
VERBOSE: Size 222 bytes                                                                                                 
VERBOSE: Executing Appx cmdlet Get-AppxPackage -PackageTypeFilter Framework                                             VERBOSE: Found framework architecture: X64                                                                              
VERBOSE: Executing Appx cmdlet Get-AppxPackage -Name Microsoft.UI.Xaml.2.8                                              VERBOSE: Executing Appx cmdlet Get-AppxPackage -Name Microsoft.VCLibs.140.00.UWPDesktop                                 VERBOSE: Downloading https://github.com/microsoft/winget-cli/releases/download/v1.11.510/DesktopAppInstaller_Dependencies.zip                
VERBOSE: Size 50180934 bytes                                                                                            
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path C:\Users\WDAGUtilityAccount\AppData\Local\Temp\j3taeuac.lbu\x64\Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64.appx -ErrorAction Stop                                                                                                       
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path                                                                    C:\Users\WDAGUtilityAccount\AppData\Local\Temp\j3taeuac.lbu\x64\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33728.0_x64.app x -ErrorAction Stop                                                                                                     
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path                                                                    https://github.com/microsoft/winget-cli/releases/download/v1.11.510/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbun dle -ErrorAction Stop -StubPackageOption UsePreference -ForceTargetApplicationShutdown                                  
VERBOSE: Failed adding package                                                                                          [https://github.com/microsoft/winget-cli/releases/download/v1.11.510/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle]. Retrying downloading it.                                                                                         
VERBOSE: Downloading                                                                                                    https://github.com/microsoft/winget-cli/releases/download/v1.11.510/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbun
dle
VERBOSE: Size 210969317 bytes
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path
C:\Users\WDAGUtilityAccount\AppData\Local\Temp\8d621e52-2d76-42ae-911f-7688756243a1\Microsoft.DesktopAppInstaller_8weky
b3d8bbwe.msixbundle -ErrorAction Stop -ForceTargetApplicationShutdown
VERBOSE: Running winget.exe with --version
Repair-WinGetPackageManager : Could not find Windows Runtime type 'Microsoft.Management.Deployment.PackageManager'.
At line:1 char:1
+ Repair-WinGetPackageManager -Latest -Verbose -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Repair-WinGetPackageManager], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.WinGet.Client.Commands.RepairWinGetPackageManagerCmdlet

Expected behavior

The same success flow we get with the previous version of the module:

PS C:\Users\WDAGUtilityAccount> Set-ExecutionPolicy Bypass -Force                                                       
PS C:\Users\WDAGUtilityAccount> install-module microsoft.winget.client  -RequiredVersion 1.11.460                                                                                                                                               NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or                               'C:\Users\WDAGUtilityAccount\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet   to install and import the NuGet provider now?                                                                           [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y                                                                                                                                                                                      Untrusted repository                                                                                                    
You are installing the modules from an untrusted repository. If you trust this repository, change its                   InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from      'PSGallery'?                                                                                                            
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A                               PS 

C:\Users\WDAGUtilityAccount> Repair-WinGetPackageManager -Latest -Verbose -Force                                     VERBOSE: Creating MTA thread                                                                                            
VERBOSE: Running winget.exe with --version                                                                              
VERBOSE: 'winget.exe' Win32Exception The system cannot find the file specified                                          VERBOSE: Executing Appx cmdlet Get-AppxPackage -Name Microsoft.DesktopAppInstaller                                      VERBOSE: Integrity category type: AppInstallerNotInstalled                                                              
VERBOSE: Downloading https://github.com/microsoft/winget-cli/releases/download/v1.11.510/DesktopAppInstaller_Dependencies.json               
VERBOSE: Size 222 bytes                                                                                                 
VERBOSE: Executing Appx cmdlet Get-AppxPackage -PackageTypeFilter Framework                                             VERBOSE: Found framework architecture: X64                                                                              
VERBOSE: Executing Appx cmdlet Get-AppxPackage -Name Microsoft.UI.Xaml.2.8                                              VERBOSE: Executing Appx cmdlet Get-AppxPackage -Name Microsoft.VCLibs.140.00.UWPDesktop                                 VERBOSE: Downloading https://github.com/microsoft/winget-cli/releases/download/v1.11.510/DesktopAppInstaller_Dependencies.zip                
VERBOSE: Size 50180934 bytes                                                                                            
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path                                                                    C:\Users\WDAGUtilityAccount\AppData\Local\Temp\iojt3vch.zag\x64\Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64.appx           -ErrorAction Stop                                                                                                       
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path                                                                    C:\Users\WDAGUtilityAccount\AppData\Local\Temp\iojt3vch.zag\x64\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33728.0_x64.app x -ErrorAction Stop                                                                                                     
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path                                                                    https://github.com/microsoft/winget-cli/releases/download/v1.11.510/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbun dle -ErrorAction Stop -StubPackageOption UsePreference -ForceTargetApplicationShutdown                                  
VERBOSE: Failed adding package
[https://github.com/microsoft/winget-cli/releases/download/v1.11.510/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu
ndle]. Retrying downloading it.
VERBOSE: Downloading
https://github.com/microsoft/winget-cli/releases/download/v1.11.510/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbun
dle
VERBOSE: Size 210969317 bytes
VERBOSE: Executing Appx cmdlet Add-AppxPackage -Path
C:\Users\WDAGUtilityAccount\AppData\Local\Temp\076edeae-4e4e-4c4f-9afd-16e60f0903c3\Microsoft.DesktopAppInstaller_8weky
b3d8bbwe.msixbundle -ErrorAction Stop -ForceTargetApplicationShutdown
VERBOSE: Running winget.exe with --version
VERBOSE: Running
C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe
with --version
VERBOSE: WinGet is in a good state.

Actual behavior

Repair-WinGetPackageManager : Could not find Windows Runtime type 'Microsoft.Management.Deployment.PackageManager'.
At line:1 char:1
+ Repair-WinGetPackageManager -Latest -Verbose -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Repair-WinGetPackageManager], TypeLoadException
    + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.WinGet.Client.Commands.RepairWinGetPackageManagerCmdlet

Environment

Windows 11 23H2 Sandbox

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIt either shouldn't be doing this or needs an investigation.PowerShellIssue related to WinGet PowerShell Module or cmdlet

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions