Winget generators
First published:
Generate the winget commands to install, uninstall or upgrade a package, in either Powershell or CMD. Each pair is a detection script and an action script, which is the shape Intune and most deployment tools expect.
Enter a package ID below — you can look one up on winget.run — then pick an action and a language.
# Set location to WinGet path
$WinGetResolve = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"
$WinGetPathExe = $WinGetResolve[-1].Path
$WinGetPath = Split-Path -Path $WinGetPathExe -Parent
set-location $WinGetPath
# Check locally installed software version
$LocalInstalledSoftware = .\winget.exe list -e --id Microsoft.Teams --accept-source-agreements
$Available = (-split $LocalInstalledSoftware[-3])[-2]
# Check if values are as expected
if ($Available -eq 'Available') { Exit 0 }
elseif ($Available -eq 'Version') { Exit 0 }
elseif (!$Available) { Exit 1 }
else { Exit 0 }
# Set location to WinGet path
$WinGetResolve = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"
$WinGetPathExe = $WinGetResolve[-1].Path
$WinGetPath = Split-Path -Path $WinGetPathExe -Parent
set-location $WinGetPath
## Run install of the software
.\winget.exe install -e --id Microsoft.Teams --silent --accept-package-agreements --accept-source-agreements --scope machine --source wingetContact me on Twitter for any issues.