I would like to use winget to search for all packages and store them in a text file or a variable. Later on I would like to sort them in a list with "Name" and "ID". Unfortunately it seems like you cannot search just for winget package Names and IDs directly using winget.exe
What I have tried so far:
Clear-Host
if (Test-Path -path "$env:temp\download_winget"){
write-host "Folder exists. Continuing..."
}
else{
write-Host "There is no folder called winget_download!`nCreating..."
mkdir "$env:temp\download_winget"
}
$get_winget_packages = winget search . --accept-source-agreements | Out-File "$env:temp\download_winget\winget_packages.txt" -Encoding utf8
(Yes I know, you can also use winget search """"
)
My Output: (a sample) (using get-content "$env:temp\download_winget\winget_packages.txt"
)
Name ID Version Ãœbereinstimmung Quelle
-----------------------------------------------------------------------------------------------------------------------
...
...
...
Windows Package Manager Manifest Creator Microsoft.WingetCreate 1.1.2.0 winget
Remote Desktop Services Infrastructure A… Microsoft.WindowsVirtualDesktopAge… 1.0.5739.9800 winget
Windows Terminal Preview Microsoft.WindowsTerminal.Preview 1.16.3463.0 winget
Windows Admin Center Microsoft.WindowsAdminCenter 1.3.53858.0 winget
Windows Assessment and Deployment Kit Microsoft.WindowsADK 10.1.22621.1 winget
...
...
...
As you can see, I displayed with gc "$env:temp\download_winget\winget_packages.txt"
the content of the earlier created file. Unfortunately some of the lines are not displayed correctly. For example:
Remote Desktop Services Infrastructure A… Microsoft.WindowsVirtualDesktopAge… 1.0.5739.9800 winget
I did not find any solution to get all winget packages full Name or full ID using winget search .
Even running this directly in PowerShell or CMD, it will display some package Names and ID not fully. Changing the Encoding to utf32, ascii, utf7 or something else wont change anything too.
Is there a workaround to show the correct/full names of all winget packages Name and ID?
I even tried it with a new powershell process with windowstyle maximized:
Start-Process powershell.exe -ArgumentList ("winget search ." , "| Out-File '$env:temp\download_winget\winget_packages_lol.txt' -Encoding utf8") -WindowStyle Maximized
My Output (a sample):
Name ID Version Ãœbereinstimmung Quelle
-----------------------------------------------------------------------------------------------------------------------
BitRecover Windows Live Mail Converter Wizard BitRecover.WindowsLiveMailConver 7.5 winget
or
Name ID Version Ãœbereinstimmung Quelle
-----------------------------------------------------------------------------------------------------------------------
ECLiPSe Constraint Logic Programming System Version  Coninfer.ECLiPSeCLP.7.0 7.0 #63 winget
My next steps would look like this:
$file = gc "$env:temp\download_winget\winget_packages_lol.txt"
$file | sort | Get-Unique | Set-Content "$env:temp\download_winget\winget_packages_lol.txt"
I would also work here with substrings, but as mentioned earlier this can't work if I can't get the full winget packages Name and ID. What can I do here?
WinGet releases have started including a Microsoft.WinGet.Client powershell module in the "Assets" section.