Why clear the Teams cache?

The Teams cache stores temporary information such as conversation history, recent files, and user settings. Over time, this cache can become large, cause errors, or prevent the application from launching properly. Deleting these files will:

  • Resolve display or connection issues
  • Free up disk space
  • Speed up Teams startup
  • Resolve the Unknown user issue

Manual steps to clean the Teams cache

  1. Close Microsoft Teams from the taskbar (icon next to the clock).
  2. Go to the folder:
    %userprofile%\appdata\local\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams
  3. Delete all files in this folder.
  4. Restart Microsoft Teams.
  5. Chats and other elements are automatically downloaded on opening.
Restarting Teams after clearing the cache might take a bit longer than usual, as the cache files need to be rebuilt. You may briefly encounter "unknown user" messages or minor graphical glitches during this process.

Although this method works, it can quickly become tedious for administrators or when it needs to be repeated.

To simplify the task, a PowerShell script is provided in the following section.

PowerShell script to clean Microsoft Teams v2 cache

# 1. Close Teams if it is running
$teamsProcess = Get-Process -Name 'ms-teams' -ErrorAction SilentlyContinue

if ($teamsProcess) {
    Write-Host 'Closing Microsoft Teams...'
    Stop-Process -Name 'ms-teams' -Force
    Start-Sleep -Seconds 2
}

# 2. Set the cache folder path
$cachePath = "$env:USERPROFILE\appdata\local\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams"

# 3. Delete all files in the cache folder in %userprofile%\appdata\local\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams

if (Test-Path $cachePath) {
    Write-Host 'Deleting Teams cache...'
    Remove-Item -Path "$cachePath\*" -Recurse -Force -ErrorAction SilentlyContinue
    Write-Host 'Teams cache deleted.' -ForegroundColor Green
}
else {
    Write-Host 'Teams cache folder does not exist or the new Teams version is not installed.' -ForegroundColor Yellow
}

# 4. Restart Teams
Write-Host 'Restarting Teams...'
Start-Process 'explorer.exe' 'shell:AppsFolder\MSTeams_8wekyb3d8bbwe!MSTeams'

How to use this script

  • Open PowerShell (user mode is sufficient for this script).
  • Copy and paste the code above.
  • Run it: it will close Teams, clean the cache, then relaunch the application.

Comments

banner-Bastien Perez
Bastien Perez's avatar

Freelance Microsoft 365 - Active Directory - Modern Workplace

France