Teams Machine-Wide Installer を使ってユーザーの Teams を管理する
Microsoft Teams は、ユーザーレベルの権限でインストールされるため、同じマシンの中でユーザーごとにバージョンが異なってしまうという事態が発生します。それを解決するのが、Teams Machine-Wide Installer です。インストールは、winget を使って
winget install Microsoft.Teams --scope machine
でインストールすることができます。
ただ、これだけではすでに各ユーザーにインストールされている Teams はアンインストールされないため、以下のような PowerShell スクリプトを作っておくと便利です。
<#
.SYNOPSIS
This script uninstalls the Teams app and removes the Teams directory for a user.
.DESCRIPTION
Use this script to remove and clear the Teams app from a computer. Run this PowerShell script for each user profile in which Teams was installed on the computer. After you run this script for all user profiles, redeploy Teams.
#>
$TeamsPath = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams')
$TeamsUpdateExePath = [System.IO.Path]::Combine($TeamsPath, 'Update.exe')
try
{
if ([System.IO.File]::Exists($TeamsUpdateExePath)) {
Write-Host "Uninstalling Teams process"
# Uninstall app
$proc = Start-Process $TeamsUpdateExePath "-uninstall -s" -PassThru
$proc.WaitForExit()
}
Write-Host "Deleting Teams directory"
Remove-Item -Path $TeamsPath -recurse
Write-Host "Deleting Teams registry"
Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Office\Teams" -Name "PreventInstallationFromMsi"
}
catch
{
Write-Output "Uninstall failed with exception $_.exception.message"
exit /b 1
}
各ユーザーが上記のスクリプトを実行後、サインアウト→サインインすると、インストールした Teams Machine-Wide Installer のバージョンに基づき、各ユーザーに Teams がインストールされます。
これで万事解決…といきそうなのですが、winget upgrade --all
で Teams Machine-Wide Installer 自身のアップグレードをしようとすると、「次のパッケージにはアップグレードを適用可能ですが、アップグレードには明示的対象化が必要です」とのメッセージが表示され、アップグレードできません。
ここでいう「明示的対象化」ですが、id(Microsoft.Teams)だけでは「入力条件に一致するインストール済みのパッケージが見つかりませんでした。」のメッセージが表示されてしまいます。正解は
winget upgrade Microsoft.Teams --scope machine
というように、--scope
もあわせて指定してあげる必要があります。指定することでアップグレードの処理自体は進むのですが、結局、「このアプリケーションの別のバージョンが既にインストールされています。」のエラーが出てアップグレードできません。仕方がないので
winget uninstall Microsoft.Teams --scope machine
winget install Microsoft.Teams --scope machine
で再インストールすることで対応します。
ディスカッション
コメント一覧
まだ、コメントがありません