PowerShell Tutorials

How to clear Microsoft Teams Cache with PowerShell

Learn how to optimize your Microsoft Teams experience by clearing the cache with PowerShell. Improve performance and resolve issues effortlessly.

Microsoft Teams can sometimes encounter issues that affect its performance. One common problem is the accumulation of cache files, which can slow down the application and impact user experience. In this comprehensive guide, we will walk you through the process of clearing Microsoft Teams cache with PowerShell, providing you with a step-by-step solution to optimize your Teams experience.

Understanding the Importance of Clearing Microsoft Teams Cache

Before diving into the technical details, let’s first understand why clearing the cache is crucial for Microsoft Teams. Cache files are temporary data stored on your computer or device, allowing the application to load faster and provide a smoother user experience. However, over time, these files can become bloated and cause performance issues. Clearing the cache not only frees up storage space but also resolves common problems such as slow loading times, sync issues, and even application crashes.

Step-by-Step Guide to Clearing Microsoft Teams Cache with PowerShell

To clear Microsoft Teams cache effectively, we will utilize the power of PowerShell, a versatile command-line tool that enables automation and system administration tasks. Follow the steps below to optimize your Teams performance:

Step 1: Open PowerShell

To begin, we need to open PowerShell, which is already available on most Windows operating systems. Press the Windows key + X on your keyboard and select “Windows PowerShell” from the menu. Make sure to run PowerShell with administrative privileges to execute the necessary commands successfully.

Step 2: Copy The PowerShell Script

Before clearing the cache, the script will ensure that all Microsoft Teams processes are stopped. The PowerShell script retrieves all running processes with the name “Teams” and forcefully stops them. By terminating the processes, we eliminate any potential conflicts during the cache clearance process.

After successfully clearing the cache, the PowerShell Script will restart Microsoft Teams.

# Stop Microsoft Teams processes
$teamsProcesses = Get-Process -Name Teams -ErrorAction SilentlyContinue
if ($teamsProcesses) {
    Write-Host "Stopping Microsoft Teams processes..."
    $teamsProcesses | ForEach-Object {
        Write-Host "Closing process ID: $($_.Id) - $($_.ProcessName)"
        $_.CloseMainWindow() | Out-Null

    # Wait for the processes to close gracefully
    Start-Sleep -Seconds 15

    # Forcefully terminate any remaining processes
    $teamsProcesses | Where-Object { !$_.HasExited } | ForEach-Object {
        Write-Host "Forcefully terminating process ID: $($_.Id) - $($_.ProcessName)"
        $_.Kill() | Out-Null

    # Wait for the processes to close gracefully
    Start-Sleep -Seconds 15

# Clear Microsoft Teams cache
$teamsCachePath = [System.IO.Path]::Combine($env:APPDATA, 'Microsoft', 'Teams')
if (Test-Path $teamsCachePath) {
    Write-Host "Clearing Microsoft Teams cache..."
    Remove-Item -Path $teamsCachePath -Recurse -Force

# Clear additional Microsoft Teams cache paths
$additionalCachePaths = @(
    [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'Cache'),
    [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'Blob_storage'),
    [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'databases'),
    [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'Cache', 'Media'),
    [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'Cache', 'Message Attachments'),
    [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'Cache', 'tmp')

# Clear additional Microsoft Teams cache paths
foreach ($path in $additionalCachePaths) {
    if (Test-Path $path) {
        Write-Host "Clearing Microsoft Teams cache from $path..."
        Remove-Item -Path $path -Recurse -Force

Write-Host "Cache cleared successfully."

Start-Process -FilePath "C:\Users\%username%\AppData\Local\Microsoft\Teams\Update.exe" --process-start-args --system-initiated


Clearing the Microsoft Teams cache with PowerShell can significantly enhance the application’s performance and resolve various issues. By following the step-by-step guide outlined in this article, you can optimize your Teams experience and enjoy seamless collaboration with your colleagues. Remember to periodically clear the cache to maintain optimal performance and mitigate any future potential issues.

I hope this article was helpful! You can find more here: PowerShell Articles

author avatar
Patrick Domingues

Leave a Comment

Stay Informed

Receive instant notifications when new content is released.