As Microsoft Teams evolves and the New Teams Client is broadly available and soon will be the default, we have to update our current machines and make sure the user only has one installation left on his computer. And of course, we want to do the installation of the new Teams client via Intune.

All about the new Teams, its new features and performance improvements you can read here: New Microsoft Teams – Microsoft Adoption

If you deploy new Computers, it's enough to change the default application in the Teams Admin Center. And if wait long enough, Office will make this transition for you.

Table of Contents

PowerShell Script for Teams Classic Removal and New Client Installation

The installation process of the new Teams client is very simpel. Just download the bootstrap installer from Microsoft and deploy run it with the correct parameters to install it machine wide and willen.

However, it can happen that the "old" Client aka. Teams Classic remains on the computer. For that reason, I run a cleanup before running the new installer.

Cleanup Teams Classic

To address the uninstallation of the Teams Classic client, I created a PowerShell script that provides a systematic approach to uninstalling Microsoft Teams Classic from both machine-wide and user-specific installations.
The script navigates through user profiles, identifies existing installations, and removes them. It also handles the removal of folders and shortcuts associated with these Teams installations.

function Uninstall-TeamsClassic($TeamsPath) {
    try {
        $process = Start-Process -FilePath "$TeamsPath\Update.exe" -ArgumentList "--uninstall /s" -PassThru -Wait -ErrorAction STOP

        if ($process.ExitCode -ne 0) {
            Write-Error "Uninstallation failed with exit code $($process.ExitCode)."
        }
    }
    catch {
        Write-Error $_.Exception.Message
    }
}

# Remove Teams Machine-Wide Installer
Write-Host "Removing Teams Machine-wide Installer"
## Get all subkeys and match the subkey that contains "Teams Machine-Wide Installer" DisplayName.
$MachineWide = Get-ItemProperty -Path $registryPath | Where-Object -Property DisplayName -eq "Teams Machine-Wide Installer"

if ($MachineWide) {
    Start-Process -FilePath "msiexec.exe" -ArgumentList "/x ""$($MachineWide.PSChildName)"" /qn" -NoNewWindow -Wait
}
else {
    Write-Host "Teams Machine-Wide Installer not found"
}

# Get all Users
$AllUsers = Get-ChildItem -Path "$($ENV:SystemDrive)\Users"

# Process all Users
foreach ($User in $AllUsers) {
    Write-Host "Processing user: $($User.Name)"

    # Locate installation folder
    $localAppData = "$($ENV:SystemDrive)\Users\$($User.Name)\AppData\Local\Microsoft\Teams"
    $programData = "$($env:ProgramData)\$($User.Name)\Microsoft\Teams"

    if (Test-Path "$localAppData\Current\Teams.exe") {
        Write-Host "  Uninstall Teams for user $($User.Name)"
        Uninstall-TeamsClassic -TeamsPath $localAppData
    }
    elseif (Test-Path "$programData\Current\Teams.exe") {
        Write-Host "  Uninstall Teams for user $($User.Name)"
        Uninstall-TeamsClassic -TeamsPath $programData
    }
    else {
        Write-Host "  Teams installation not found for user $($User.Name)"
    }
}

# Remove old Teams folders and icons
$TeamsFolder_old = "$($ENV:SystemDrive)\Users\*\AppData\Local\Microsoft\Teams"
$TeamsIcon_old = "$($ENV:SystemDrive)\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams*.lnk"
Get-Item $TeamsFolder_old | Remove-Item -Force -Recurse
Get-Item $TeamsIcon_old | Remove-Item -Force -RecurseCode language: PowerShell (powershell)

Installing the New Teams

In comparison to the cleanup part this is very veeeeeeeeeeeeeeeeeery easy 😉

Just download the bootstrap.exe from Microsoft and call it with the Parameter -p for a installation.

& '.\teamsbootstrapper.exe' -pCode language: PowerShell (powershell)

Deploy new Teams via Intune

Now everything together ist the package you can download above.
To upload it to your Intune environment, follow these steps:

  1. Login to Intune
  2. Navigate to: Apps > Windows
  3. Click +Add
  4. Choose: Windows app (Win32)
  5. Upload the TeamsNew.intunewin
  6. Fill out at least the Name, Description and Publisher
  7. The Install and Uninstall command is:
    • %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -executionpolicy bypass -command .\install.ps1
    • %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -executionpolicy bypass -command .\uninstall.ps1
  8. Install behavior: system
  9. In the Requirements choose:
    Operating system architecture: 64-bit
    Minimum OS: what suites you, if you don't have special requirements choose 2004
  10. In the Detection rules choose "Use a custom detection script" and upload the detection.ps1
  11. You can skip the next three steps Dependencies, Supersedence and Scope tags
  12. In the Assigments add your desired groups and your good to go.

Conclusion

In summary, transitioning to the new Microsoft Teams client is made seamless with the provided PowerShell script and Intune deployment. The cleanup process ensures the removal of the old Teams Classic client, leaving a clean slate for installation.