How-to: Clear Microsoft Teams Cache

In most cases Microsoft Teams will manage its own cache, but if you do need to clear it for troubleshooting here is a script to do that.
This will delete only the Teams cache for the current user, it will not clear any browser cache, cookies or favorites.
Nevertheless use at your own risk:

# ./clear-teams.ps1

# Clear MS Teams cache

$challenge = Read-Host "Are you sure you want to delete the Microsoft Teams Cache (Y/N)?"

if ($challenge -eq "Y"){
    Write-Host "Stopping Teams" -ForegroundColor Yellow
    Get-Process -ProcessName Teams | Stop-Process -Force
    Clear
    Write-Host "Teams Stopped, please wait..." -ForegroundColor Green
    
    Start-Sleep -Seconds 5
    Write-Host "Clearing Teams Disk Cache"
    try{
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\application cache\cache" -force | Remove-Item -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" -recurse -force | Remove-Item -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\cache" | Remove-Item -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\databases" -recurse -force | Remove-Item -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\gpucache" -force | Remove-Item -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Indexeddb" -recurse -force | Remove-Item -recurse -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Local Storage" -recurse -force | Remove-Item -recurse -Confirm:$false
        Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\tmp" -recurse -force | Remove-Item -Confirm:$false
    }catch{
        echo $_
    }
    Write-Host "Cleanup Complete." -ForegroundColor Green
}

# To delete the cache for ALL users, change the paths above replacing $env:APPDATA with 'C:\Users\*\AppData'

“why are we still here? just to suffer? every day i get emails” ~ serpentwife.tumblr.com, 2019

Related PowerShell Cmdlets:

Remove-Item - Remove an item.
Stop-Process - Stop a running process.


 
Copyright © 1999-2021 SS64.com
Some rights reserved