Skip to content

Instantly share code, notes, and snippets.

@iamacarpet
Created September 23, 2021 11:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamacarpet/959b2a43d3664fe773c6e7804a2febae to your computer and use it in GitHub Desktop.
Save iamacarpet/959b2a43d3664fe773c6e7804a2febae to your computer and use it in GitHub Desktop.
Force a Microsoft Teams update
$ProgressPreference = 'SilentlyContinue'
$TeamsSettings = $HOME + "\AppData\Roaming\Microsoft\Teams\settings.json"
$Setting = Get-Content $TeamsSettings -ErrorAction Continue | ConvertFrom-Json | Select Version
$Version = $Setting.Version
echo "Checking for updates..."
$UpdateInfo = curl "https://teams.microsoft.com/desktopclient/update/$Version/windows/x64?ring=general"
$UpdateData = $UpdateInfo | ConvertFrom-json
if ($UpdateData.isUpdateAvailable) {
echo "Starting update process..."
$tmpdir = $HOME + "\AppData\Local\Temp\teamsupdate"
mkdir $tmpdir
cd $tmpdir
echo "Downloading large update file..."
$updateFile = $UpdateData.nugetPackagePath | Split-Path -leaf
curl -o $updateFile $UpdateData.nugetPackagePath
echo "Downloading smaller update file..."
curl -o "RELEASES" $UpdateData.releasesPath
echo "Triggering update..."
$TeamsPath = $HOME + "\AppData\Local\Microsoft\Teams"
$TeamsUpdatePath = $TeamsPath + "\Update.exe"
cd $TeamsPath
& $TeamsUpdatePath --update=$tmpdir
echo "Waiting for update to complete..."
Start-Sleep -Seconds 300
echo "Killing all existing instances of Teams..."
& Taskkill /IM Teams.exe /F
echo "Waiting for Teams to exit..."
Start-Sleep -Seconds 5
echo "Starting a new instance of Teams..."
& $TeamsUpdatePath --processStart "Teams.exe"
echo "Done"
} else {
echo "No updates available."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment