Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve winget output (type: system.array) to be actionable by PowerShell #4521

Open
Karl-WE opened this issue May 31, 2024 · 7 comments
Open
Labels
Issue-Feature This is a feature request for the Windows Package Manager client.

Comments

@Karl-WE
Copy link
Contributor

Karl-WE commented May 31, 2024

Description of the new feature / enhancement

Would like to see the winget output stored with properties, so one can work with them in PowerShell.
The current output saved into a variable is of type System.Array but saved unstructured, more like with 'start-transcript'

  • The output even includes any output including characters from the progress bar.
  • Currently the output is saved "as-is" this may include Unicode issues as.
    Reference: screenshots below.

Affected products

winget cli
winget PowerShell module
Tested with v1.8.924-preview

Background

Until #4507 never bothered to combine winget with other PowerShell commands. But now a customer request made it a requirement.

Examples

$apps = winget upgrade
$apps = winget list
$app1 = winget list Putty.Putty

Native Microsoft Terminal output of winget upgrade
image

This results into a variable of type system.array. It is not possible to fetch data from the columns

$app1.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array

Variable output of $app1 from $app1 = winget list Putty.Putty

image

Proposed technical implementation details

Feature request 1:
Currently if I need to lookup what's the latest version of Putty this is not an easy task when automated via PowerShell.
One can only vaguely use -match / -like
It should become possible to use the data of columns and rows.

When the output would be structured, I could use regular PowerShell code to identify the content, like:

#identify if Putty is installed and matches a specific version
$apps | Where-Object name -eq "Putty.Putty" and version -like "*0.78*"

or

#identify if Putty is installed and return the latest available version
($apps | Where-Object name -eq "Putty.Putty").available

and so on.

Feature request 2:
The column names should be static (en-US) and independent from the console output, which is localized.
If column names would be localized as per output, this would make automation very difficult when scripting is applied on a fleet of OS with different languages / language packs or native OS language for Windows Client or Windows Server.

@Karl-WE Karl-WE added the Issue-Feature This is a feature request for the Windows Package Manager client. label May 31, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label May 31, 2024
@Karl-WE
Copy link
Contributor Author

Karl-WE commented May 31, 2024

GitHub actions mentioned #1506 and within this #221. Both closed. Unfortunately, miss to see the request of 1506 satisfied by any mentioned PR, nor was I aware about a potential duplicate. AI works great :)

@stephengillie
Copy link

Please consider using the WinGet PowerShell cmdlets, such as Find-WinGetPackage, as they provide PSObjects.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage Issue need to be triaged label May 31, 2024
@Karl-WE
Copy link
Contributor Author

Karl-WE commented May 31, 2024

@stephengillie that's great news. Thank you for sharing this.
If the work is already done, I certainly tend to close this FR.

Right now, I wonder, how to deploy winget PS module at scale and keeping it updated.

Hindrances I can think of right now, are

  • blocked psgallery / nuget (some org's security concerns)
  • limited local permissions
  • deploy and maintain PS module on Windows Server (AD) vs Clients (AD less / Entra joined only).

Could consider is a scheduled task to do that with a PS script.

Any better ideas?

@denelon
Copy link
Contributor

denelon commented May 31, 2024

I know there is work in progress to support Azure Container Registry (ACR) as a "local"/"private" PowerShell Gallery. It's also possible to host NuGet packages in Azure Dev Ops, and there are some commercial products as well.

The Microsoft.WinGet.Client module works for PowerShell 7 (limited capabilities in Windows PowerShell). We've got work to figure out how to make everything work in Windows PowerShell. Microsoft.WincGet.Configuration handles configuration and doesn't depend on the client directly.

@Karl-WE
Copy link
Contributor Author

Karl-WE commented Jun 1, 2024

The PS7 dependency is fair. It seems like Windows Server 2025 will not likely be shipped with PS7.

@denelon how do you think about whether it's feasible to keep up his feature request, or close and point to PS module, despite the dependencies of nuget, psgallery and, best case, PS 7?

@Karl-WE
Copy link
Contributor Author

Karl-WE commented Jun 10, 2024

Another similar request is #964 which also emphazise why PowerShell Module of winget is not a good generic solution and it would make sense to triage this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature This is a feature request for the Windows Package Manager client.
Projects
None yet
Development

No branches or pull requests

3 participants