Created
September 23, 2021 11:05
-
-
Save iamacarpet/959b2a43d3664fe773c6e7804a2febae to your computer and use it in GitHub Desktop.
Force a Microsoft Teams update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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