Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (2024)

Microsoft Teams is not like your average program when it comes to installing and uninstall it. The problem with Microsoft Teams is that it’s installed for every user, in the user’s AppData (or program data sometimes). Besides that, we also have Microsoft Teams machine-wide installer, which will automatically install Teams when a user logs in.

Cleaning things up with Microsoft Teams can be quite challenging. I tried for example to remove and re-install Teams for a user recently. The user got an error, Microsoft Teams Installation Has Failed with every update of Microsoft Teams

After removing everything and re-installing Teams he ended up with a blank Teams app. So no chat history and no more Teams channels (even though online everything was still visible).

In this article, I will give you some tips and scripts to remove and cleanup Teams so you can re-install it again.

Make Teams a bit more fun with these funny backgrounds for Microsoft Teams

Fix Microsoft Teams Installation Has Failed

One of the most common errors with Microsoft Teams is the error Installation Has Failed which can appear when Teams tries to update. This error can keep coming back with every update and is pretty annoying.

Simply re-installing Teams isn’t the solution. It will work for now, but the error will probably re-appear with the next update.

The only way to really fix the problem is to remove the local cache and restart Microsoft Teams:

  1. Close Microsoft Teams
  2. Press Windows key + R
  3. Type %appdata% and press enter
Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (1)
  1. Open the folder Microsoft
  2. Delete the folder Teams

5. Restart Teams

You can also use the the PowerShell script below to remove the Microsoft Teams Cache.

Uninstalling Microsoft Teams

We start with the easy part, simply uninstalling Microsoft Teams. Some people commented that their Microsoft Teams keeps reinstalling itself after they have uninstalled it. This is most of the time caused by the Machine-Wide installer.

So to completely uninstall Microsoft Teams you will have to remove both Microsoft Teams and the Teams Machine-Wide Installer.

  1. Open Settings > Apps > Apps & Features
  2. Search for Teams
  3. Remove all the apps (yes, I got two Machine-Wide installers… don’t ask why)
Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (3)

Uninstall Microsoft Teams with PowerShell

I like to automate things as much as possible, so of course, we also have a PowerShell script to uninstall Microsoft Teams.

The script will remove the Machine-Wide installer and Microsoft Teams self. Make sure you run the PowerShell script in an elevated mode. You can do this by opening PowerShell as Admin

function unInstallTeams($path) {$clientInstaller = "$($path)\Update.exe" try { $process = Start-Process -FilePath "$clientInstaller" -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 InstallerWrite-Host "Removing Teams Machine-wide Installer" -ForegroundColor Yellow$MachineWide = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Teams Machine-Wide Installer"}$MachineWide.Uninstall()# Remove Teams for Current Users$localAppData = "$($env:LOCALAPPDATA)\Microsoft\Teams"$programData = "$($env:ProgramData)\$($env:USERNAME)\Microsoft\Teams"If (Test-Path "$($localAppData)\Current\Teams.exe") {unInstallTeams($localAppData)}elseif (Test-Path "$($programData)\Current\Teams.exe") {unInstallTeams($programData)}else {Write-Warning "Teams installation not found"}

The script will check for the two possible installation locations of Teams and remove it when found.

If you want to run this script for multiple users (on the same computer), then you can use the following part in place of the Remove Teams for Current User section:

# Get all Users$Users = Get-ChildItem -Path "$($ENV:SystemDrive)\Users"# Process all the Users$Users | ForEach-Object { Write-Host "Process user: $($_.Name)" -ForegroundColor Yellow #Locate installation folder $localAppData = "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams" $programData = "$($env:ProgramData)\$($_.Name)\Microsoft\Teams" If (Test-Path "$($localAppData)\Current\Teams.exe") { unInstallTeams($localAppData) } elseif (Test-Path "$($programData)\Current\Teams.exe") { unInstallTeams($programData) } else { Write-Warning "Teams installation not found for user $($_.Name)" }}

Uninstall Teams Machine-wide Installer

Just to be clear, you can safely uninstall the Teams Machine-wide installer. All it does is install Teams for every user that signs in.

You can uninstall the Teams Machine-wide installer in the settings screen or with a PowerShell script.

  1. Open Settings > Apps > Apps & Features
  2. Search for Teams
  3. Uninstall Teams Machine-Wide Installer
Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (4)

You can also remove the Teams Machine-Wide installer with PowerShell. This can be really useful if you need to remove it from multiple computers. Make sure you run the PowerShell script in an elevated mode.

You can open PowerShell as Administrator from start menu.

# Remove Teams Machine-Wide InstallerWrite-Host "Removing Teams Machine-wide Installer" -ForegroundColor Yellow$MachineWide = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Teams Machine-Wide Installer"}$MachineWide.Uninstall()

Microsoft Teams Clear Cache

So I had an occasion where I had to remove Microsoft Teams for users, but after re-installing Teams came back with no history. The only solution to fix this was to clear the cache of Microsoft Teams.

The problem is that there is not one location for the Microsoft Teams’ cache. I expected it to be in the roaming AppData, but it turned out to be not the only location. We also need to clear the Chrome and Edge Cache to completely remove it.

Mark Vale had already created a really nice PowerShell script to clear the Microsoft Teams Cache, so we are going to use that:

# Author: Mark Vale$clearCache = Read-Host "Do you want to delete the Teams Cache (Y/N)?"$clearCache = $clearCache.ToUpper()if ($clearCache -eq "Y"){ Write-Host "Stopping Teams Process" -ForegroundColor Yellow try{ Get-Process -ProcessName Teams | Stop-Process -Force Start-Sleep -Seconds 3 Write-Host "Teams Process Sucessfully Stopped" -ForegroundColor Green }catch{ echo $_ } Write-Host "Clearing Teams Disk Cache" -ForegroundColor Yellow try{ Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\application cache\cache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\databases" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\cache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\gpucache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Indexeddb" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Local Storage" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\tmp" | Remove-Item -Confirm:$false Write-Host "Teams Disk Cache Cleaned" -ForegroundColor Green }catch{ echo $_ } Write-Host "Stopping Chrome Process" -ForegroundColor Yellow try{ Get-Process -ProcessName Chrome| Stop-Process -Force Start-Sleep -Seconds 3 Write-Host "Chrome Process Sucessfully Stopped" -ForegroundColor Green }catch{ echo $_ } Write-Host "Clearing Chrome Cache" -ForegroundColor Yellow try{ Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Cache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Cookies" -File | Remove-Item -Confirm:$false Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Web Data" -File | Remove-Item -Confirm:$false Write-Host "Chrome Cleaned" -ForegroundColor Green }catch{ echo $_ } Write-Host "Stopping IE Process" -ForegroundColor Yellow try{ Get-Process -ProcessName MicrosoftEdge | Stop-Process -Force Get-Process -ProcessName IExplore | Stop-Process -Force Write-Host "Internet Explorer and Edge Processes Sucessfully Stopped" -ForegroundColor Green }catch{ echo $_ } Write-Host "Clearing IE Cache" -ForegroundColor Yellow try{ RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 8 RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 2 Write-Host "IE and Edge Cleaned" -ForegroundColor Green }catch{ echo $_ } Write-Host "Cleanup Complete... Launching Teams" -ForegroundColor Green Start-Process -FilePath $env:LOCALAPPDATA\Microsoft\Teams\current\Teams.exe Stop-Process -Id $PID}

This script will only clear the cache of Microsoft Teams and restart Teams when done.

You can also combine the cleanup and delete script to do everything in one run:

# Clearing Teams Cache by Mark Vale# Uninstall Teams by Rudy Mens$clearCache = Read-Host "Do you want to delete the Teams Cache (Y/N)?"$clearCache = $clearCache.ToUpper()$uninstall= Read-Host "Do you want to uninstall Teams completely (Y/N)?"$uninstall= $uninstall.ToUpper()if ($clearCache -eq "Y"){ Write-Host "Stopping Teams Process" -ForegroundColor Yellow try{ Get-Process -ProcessName Teams | Stop-Process -Force Start-Sleep -Seconds 3 Write-Host "Teams Process Sucessfully Stopped" -ForegroundColor Green }catch{ echo $_ } Write-Host "Clearing Teams Disk Cache" -ForegroundColor Yellow try{ Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\application cache\cache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\databases" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\cache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\gpucache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Indexeddb" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Local Storage" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\tmp" | Remove-Item -Confirm:$false Write-Host "Teams Disk Cache Cleaned" -ForegroundColor Green }catch{ echo $_ } Write-Host "Stopping Chrome Process" -ForegroundColor Yellow try{ Get-Process -ProcessName Chrome| Stop-Process -Force Start-Sleep -Seconds 3 Write-Host "Chrome Process Sucessfully Stopped" -ForegroundColor Green }catch{ echo $_ } Write-Host "Clearing Chrome Cache" -ForegroundColor Yellow try{ Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Cache" | Remove-Item -Confirm:$false Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Cookies" -File | Remove-Item -Confirm:$false Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Web Data" -File | Remove-Item -Confirm:$false Write-Host "Chrome Cleaned" -ForegroundColor Green }catch{ echo $_ } Write-Host "Stopping IE Process" -ForegroundColor Yellow try{ Get-Process -ProcessName MicrosoftEdge | Stop-Process -Force Get-Process -ProcessName IExplore | Stop-Process -Force Write-Host "Internet Explorer and Edge Processes Sucessfully Stopped" -ForegroundColor Green }catch{ echo $_ } Write-Host "Clearing IE Cache" -ForegroundColor Yellow try{ RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 8 RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 2 Write-Host "IE and Edge Cleaned" -ForegroundColor Green }catch{ echo $_ } Write-Host "Cleanup Complete..." -ForegroundColor Green}if ($uninstall -eq "Y"){ Write-Host "Removing Teams Machine-wide Installer" -ForegroundColor Yellow $MachineWide = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Teams Machine-Wide Installer"} $MachineWide.Uninstall() function unInstallTeams($path) {$clientInstaller = "$($path)\Update.exe" try { $process = Start-Process -FilePath "$clientInstaller" -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 } } #Locate installation folder $localAppData = "$($env:LOCALAPPDATA)\Microsoft\Teams" $programData = "$($env:ProgramData)\$($env:USERNAME)\Microsoft\Teams" If (Test-Path "$($localAppData)\Current\Teams.exe") { unInstallTeams($localAppData) } elseif (Test-Path "$($programData)\Current\Teams.exe") { unInstallTeams($programData) } else { Write-Warning "Teams installation not found" }}

Wrapping Up

I hope these scripts helped you remove and clean up Microsoft Teams. If you want to re-install Microsoft Teams, then make sure you check out this article.

If you have any questions just drop a comment below.

Again thanks to Mark Vale for the clean-up script!

0 Shares

Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (6)

Hey! I'm Ruud. I work as an IT Consultant in the Netherlands and love to write about IT, Microsoft 365, PowerShell and Smart Home stuff.

Follow LazyAdmin.nl on:

Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (7)Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (8)Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (9)Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (10)Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (11)

Microsoft Teams Uninstall, Reinstall, and Cleanup Guide & Scripts — LazyAdmin (2024)
Top Articles
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 6606

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.