Skip to content

Repair-WinGetPackageManager outputs noise in PowerShell transcripts #4005

@janegilring

Description

@janegilring

Brief description of your issue

The log file for the WinGet bootstrapping outputs the following:
The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.

This happens even though we don`t call winget.exe directly in the bootstrapping-script, we just run Repair-WinGetPackageManager to install WinGet.

Simple repro on a fresh 2022 VM:
image

I suspect this is due to some internal workings of Repair-WinGetPackageManager checking for the existence of winget before installing it if not present.

I`m not too familiar with C# - but seems like the relevant parts are here
https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs#L91
and here
https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Client.Engine/Common/WinGetIntegrity.cs#L98

Suggestions for possible solutions:

  • Add a -Force switch to Repair-WinGetPackageManager to make it skip checking existence of winget.exe
  • Add a separate Install-WinGetPackageManager which can be used for bootstrapping scenarios
  • Suppress the output of the presence of winget.exe

Steps to reproduce

On a machine which does not have WinGet installed, open PowerShell 7 and run the following:

Start-Transcript
Install-Module -Name Microsoft.WinGet.Client
$null = Repair-WinGetPackageManager -AllUsers
Stop-Transcript

Expected behavior

Repair-WinGetPackageManager should not output the following to the PowerShell transcript log file:
`The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.

Actual behavior

Repair-WinGetPackageManager outputs the following to the PowerShell transcript log file:
`The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.

Environment

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

Windows: Windows.Server v10.0.20348.2159
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.3421.0

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

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions