Param( [Parameter(Mandatory=$true)] [string]$WingetPackageID ) Start-Transcript -Path "C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\$($WingetPackageID)_Install.log" -Append Write-Host "Starting Transcript for Winget Installation" -ForegroundColor Green try { Write-Host "Attempting to install $($WingetPackageID) via Winget" $ResolveWingetPath = Resolve-Path 'C:\Program Files\WindowsApps\*\winget.exe' if ($ResolveWingetPath){ $WingetPath = $ResolveWingetPath[-1].Path Write-Host $WingetPath } else { Throw "Unable to find Winget" } & $WingetPath 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