Last active
January 18, 2025 03:49
-
-
Save RReverser/efa63788a193ef8011b09e1d1d6692d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
choco list --limit-output | |
# Extract name and find corresponding winget package | |
| ForEach-Object -Parallel { | |
$chocoName = $_.Split('|')[0] | |
Get-WinGetPackage $chocoName -Count 1 |% { | |
@{ | |
'chocoName' = $chocoName | |
'wingetPackage' = $_.Name | |
} | |
} | |
} | |
# This part can't be parallelised as it requires user interaction. | |
|% { | |
Write-Output "Chocolatey package $($_.chocoName) is installed." | |
Write-Output "Winget package $($_.wingetPackage) looks like a match." | |
$confirmation = Read-Host "Do you want to delete Chocolatey package?" | |
if ($confirmation.ToUpper() -eq "Y") { | |
# Remove the package from Chocolatey without actually uninstalling. | |
choco uninstall "$($_.chocoName)" --skip-powershell --skip-autouninstaller --limit-output | |
} | |
} | |
# Old version that used to list WinGet packages and search in Chocolatey instead: | |
# Sometimes it might find more matches. | |
# | |
# Get-WinGetPackage | |
# # Search for matches in parallel - this doesn't require user interaction, so can be sped up significantly. | |
# | ForEach-Object -Parallel { | |
# $wingetPackage = $_.Name | |
# $chocolateyPackageInfo = choco list --yes --by-id-only "$wingetPackage" --limit-output | |
# if ($chocolateyPackageInfo) { | |
# return @{ | |
# 'wingetPackage' = $wingetPackage | |
# 'chocolateyPackageInfo' = $chocolateyPackageInfo | |
# } | |
# } | |
# else { | |
# return $null | |
# } | |
# } | |
# | Where-Object { $_ } | |
# # Only pause to ask the user & uninstall the package when there are matches. | |
# | ForEach-Object { | |
# $wingetPackage = $_.wingetPackage | |
# $chocolateyPackageInfo = $_.chocolateyPackageInfo | |
# Write-Output "Chocolatey package $chocolateyPackageInfo is installed." | |
# Write-Output "Winget package $wingetPackage is available." | |
# $confirmation = Read-Host "Do you want to delete Chocolatey package?" | |
# if ($confirmation -eq "Y" -or $confirmation -eq "y") { | |
# $chocoName = ($chocolateyPackageInfo -split '\|')[0] | |
# # Remove the package from Chocolatey without actually uninstalling. | |
# choco uninstall "$chocoName" --skip-powershell --skip-autouninstaller --limit-output | |
# } | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment