Param( [Parameter(Mandatory=$true)] [string]$WingetPackageID ) Start-Transcript -Path "C:\Users\Public\Downloads\$($WingetPackageID)_Install.log" -Append Write-Host "Starting Transcript for Winget Installation" -ForegroundColor Green try { Write-Host "Attempting to uninstall $($WingetPackageID) via Winget" $ResolveWingetPath = Join-Path $env:USERPROFILE 'AppData\Local\Microsoft\WindowsApps\winget.exe' if ($ResolveWingetPath){ Write-Host "winget.exe found at: $ResolveWingetPath" } else { Throw "winget.exe not found in the current user's profile." } & $ResolveWingetPath uninstall --exact $WingetPackageID --silent --accept-source-agreements --disable-interactivity } Catch { Throw "Failed to install Package. [$($_.Exception.Message)] See: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir" } Stop-Transcript