[英]Find with winget.exe all packages and save the package ID and package Name with powershell
I would like to use winget to search for all packages and store them in a text file or a variable.我想使用winget来搜索所有包并将它们存储在文本文件或变量中。 Later on I would like to sort them in a list with "Name" and "ID".
稍后我想用“名称”和“ID”将它们排序在列表中。 Unfortunately it seems like you cannot search just for winget package Names and IDs directly using winget.exe
不幸的是,您似乎不能直接使用winget.exe搜索 winget package 名称和 ID
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 """"
) (是的,我知道,您也可以使用
winget search """"
)
My Output: (a sample) (using get-content "$env:temp\download_winget\winget_packages.txt"
)我的 Output:(示例)(使用
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.如您所见,我使用
gc "$env:temp\download_winget\winget_packages.txt"
显示了先前创建的文件的内容。 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.
我没有找到任何解决方案来使用
winget search.
Even running this directly in PowerShell or CMD, it will display some package Names and ID not fully.即使直接在 PowerShell 或 CMD 中运行,它也会显示一些 package 的名称和 ID 不完整。 Changing the Encoding to utf32, ascii, utf7 or something else wont change anything too.
将编码更改为 utf32、ascii、utf7 或其他内容也不会改变任何内容。
Is there a workaround to show the correct/full names of all winget packages Name and ID?是否有解决方法来显示所有 winget 包名称和 ID 的正确/全名?
I even tried it with a new powershell process with windowstyle maximized:我什至尝试了一个新的 powershell 进程,窗口样式最大化:
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):我的 Output(示例):
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.我也会在这里使用子字符串,但如前所述,如果我无法获得完整的 winget 包名称和 ID,这将无法工作。 What can I do here?
我可以在这里做什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.