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 # } # }