How to run winget command and show its progress bar and size of update if it is inside a variable ( PowerShell )

522 Views Asked by At

I am working on a PowerShell command that updates all my apps with one click but I ran into a problem I stored the winget command inside a variable $upgradeResult the code was $upgradeResult=winget upgrade -u --id $($_.Id) --silent --accept-source-agreements I noticed that the code runs without displaying anything so I added Write-Host $upgradeResult but there is an issue with the output it shows like this

    -     \     |                                                                                                                               -     \     |                                                                                                                           No available upgrade found. No newer package versions are available from the configured sources.

I don't know why it shows these characters - \ | - \ |

I tried Invoke-Expression and I tried to add | Out-String after the code but nothing seems to work it still shows these random characters - \ | - \ |

1

There are 1 best solutions below

0
Demitrius Nelon On

You might want to try the Microsoft.WinGet.Client PowerShell module. It's still in preview, but you're going to get better output objects.

https://www.powershellgallery.com/packages/Microsoft.WinGet.Client/