Jonathan

home

Articles

projects

tools

contact

Jonathan
# 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 winget

Last updated: June 15, 2024
Contact me on Twitter for any issues.

You can also find me on these sites

GitHubLinkedInStackOverflowEduGeekMicrosoft LearnMicrosoft CommunityCodeStats

© 2024 Jonathan