Teams Deployment and Update for Windows 10 and later, and Server 2019 and later
UPDATE
This updated version now checks the downloaded msix against the installed version, and only updates if it is newer.
Microsoft has modified the bootstrapper to allow installing the Teams add-in for Outlook during the install, so I have modified the script below to reflect that process.
While testing out the newer versions of Teams for all user installs, I noticed that it was no longer updating properly via the launch, close, relaunch process. So I went back to the PowerShell drawing board and created a brand new scripted deployment process for Teams that will properly install the latest version of Teams, and remove Teams and the Outlook Teams add-in, then install it during an update process.
As 2019 uses different installation methods than 2022/2025, you will see in the script that detection for proper branching. Also for new installs if you don't have the proper Dot Net Framework 4.8 or later installed, a requirement for the Outlook add-in, the script will install it for you. It also will reboot after that process, restarting the PowerShell script after that reboot will continue the process.
I worked to address any of the false red error messages from showing in the log and screen. But if you experience anything, let me know so I can adjust the script.
As with all PowerShell Scripts, make sure to sign it with an internal domain certificate authority to prevent having to adjust your Execution Policy settings.
#Teams Install
#Download latest MSIX version
$MSIXDownloadURI = "https://go.microsoft.com/fwlink/?linkid=2196106"
$MSIXPath = Join-Path "$($env:TEMP)" "MSTeams-x64.msix"
(New-Object System.Net.WebClient).DownloadFile($MSIXDownloadURI, $MSIXPath)
#Check to see if Downloaded Version is Newer than Installed Version
Add-Type -AssemblyName System.IO.Compression.FileSystem
# Open the MSIX file as a ZIP archive
$zip = [System.IO.Compression.ZipFile]::OpenRead($msixPath)
# Locate the AppxManifest.xml entry
$manifestEntry = $zip.Entries | Where-Object { $_.FullName -eq "AppxManifest.xml" }
if ($manifestEntry) {
$reader = New-Object System.IO.StreamReader($manifestEntry.Open())
$manifestContent = $reader.ReadToEnd()
$reader.Close()
$zip.Dispose()
[xml]$manifestXml = $manifestContent
# Store version in a variable
$downloadversion = $manifestXml.Package.Identity.Version
}
else {
Write-Host "AppxManifest.xml not found in the MSIX file."
Write-Host "There is a problem with the Teams download file. Fix this issue before continuing."
exit
}
try {
$package = Get-AppxPackage -Name "MSTeams"
if ($package) {
$installedversion = $package.Version
}
else {
$installedversion = "000"
}
}
catch {
$installedversion = "000"
}
if ($downloadversion.Trim() -gt $Installedversion.Trim()) {
$winver = Get-ComputerInfo | Select-Object -ExpandProperty WindowsProductName
$TeamsKeyTest = test-path -path "HKLM:\SOFTWARE\Microsoft\Teams"
If ($TeamsKeyTest) { $TeamUpdateRegistryTest = (Get-Item "HKLM:\SOFTWARE\Microsoft\Teams").Property -contains "disableAutoUpdate" }else {}
If ($TeamUpdateRegistryTest) {
Write-Output "Check to see if Teams auto update is disabled, and remove that setting."
Write-Output "It will be re-enabled at the end of the process."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Teams" -Name "disableAutoUpdate"
}
else {}
#Download and install Teams
# Server 2019
If ($winver -like "Windows Server 2019*") {
#Check for DotNet 4.8 or later - required for the Teams add-in for Outlook
if ((Get-ItemPropertyValue -LiteralPath 'HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release) -ge 528049) {
Write-Host "Dot Net is up to date."
}
else {
Write-output "Dot Net Framework 4.8 or later is not installed."
Write-output "This is required for the Teams add-in for Outlook"
Write-output "Rerun this install after installing Dot Net Framework and rebooting"
exit
}
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Appx" -Name "AllowAllTrustedApps" -Value "00000001" -PropertyType DWORD -Force
$DISM = "c:\windows\system32\Dism.exe"
$Switches = " /Online /Add-ProvisionedAppxPackage /PackagePath:$MSIXPath /SkipLicense"
Write-output "Installing Teams for Windows Server 2019"
$Team2Installproc = Start-Process -FilePath $DISM -ArgumentList $Switches -PassThru -Wait
$Team2Installproc.WaitForExit()
Write-output "Teams has completed installation, now installing the Teams Outlook Add-in"
# Install latest Teams Meeting Add-in
$UpdatedTeams = (Get-ChildItem -Path "C:\Program Files\WindowsApps" -Filter "MSTeams_*" -Directory).Fullname | Sort-Object name | Select-Object -First 1
$installableversion = Get-AppLockerFileInformation -Path $UpdatedTeams"\MICROSOFTTEAMSMEETINGADDININSTALLER.MSI" | Select-Object -ExpandProperty Publisher | Select-Object BinaryVersion
$getversionnumber = $installableversion.BinaryVersion.toString()
$TeamsAddinInstall = start-process -filepath "C:\Windows\System32\msiexec.exe"-argumentList '/i MicrosoftTeamsMeetingAddinInstaller.msi /qn ALLUSERS=1 /norestart TARGETDIR="C:\Program Files (x86)\Microsoft\TeamsMeetingAddin\', $getversionnumber, '"' -WorkingDirectory $UpdatedTeams -Passthru -Wait
$TeamsAddinInstall.WaitForExit()
}
else {
#All other OSes
#Check for DotNet 4.8 or later - required for the Teams add-in for Outlook
if ((Get-ItemPropertyValue -LiteralPath 'HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release) -ge 528049) {
Write-Host "Dot Net is up to date."
}
else {
Write-output "Dot Net Framework 4.8 or later is not installed."
Write-output "This is required for the Teams add-in for Outlook"
Write-output "Rerun this install after installing Dot Net Framework and rebooting"
exit
}
Write-Host "Download latest Teams installer"
$TeamDownloadURI = "https://go.microsoft.com/fwlink/?linkid=2243204&clcid=0x409"
$TeamPath = Join-Path "$($env:TEMP)" "teamsbootstrapper.exe"
Write-Output "Downloading Now"
(New-Object System.Net.WebClient).DownloadFile($TeamDownloadURI, $TeamPath)
$Execute2Setup = " -p -o $MSIXPath --installTMA"
Write-output "Installing Teams"
$Team2Installproc = Start-Process -FilePath $TeamPath -ArgumentList $Execute2Setup -PassThru -Wait
$Team2Installproc.WaitForExit()
}
#Disable Teams Auto-Updates for users.
$TeamsKeyTest = test-path -path "HKLM:\SOFTWARE\Microsoft\Teams"
If ($TeamsKeyTest) { New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Teams" -Name "disableAutoUpdate" -Value "00000001" -PropertyType DWORD -Force }
else {
New-Item "HKLM:\SOFTWARE\Microsoft\Teams"
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Teams" -Name "disableAutoUpdate" -Value "00000001" -PropertyType DWORD -Force
}
}
else {
Write-Host "Downloaded Teams: "$downloadversion
Write-Host "Installed Teams: "$Installedversion
Write-Host "Installed version is newer or equal to the Downloaded Version. No update needed."
}