Skip to content
PowerShell Script

PowerShell Script – Clear Microsoft Teams Cache (Updated)

When your Microsoft Teams application is behaving strange or have issues, one of the first steps in troubleshooting is to clear the cache. You can do this manually or using a script..

If you check Clear Teams cache Microsoft Learn (at present time), they recommend deleting the cache directory.

To see the files it will delete; open the Run dialog (Win+R). Enter %localappdata%\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams, and click OK.

This script also allows you to use -Hard to delete the Root directory.
To see the folders you delete; open the Run dialog (Win+R). Enter %localappdata%\Packages\MSTeams_8wekyb3d8bbwe, and click OK.

Check my repo on GitHub, to get the latest updates in case I create some new options or change the standard folders.

9 thoughts on “PowerShell Script – Clear Microsoft Teams Cache (Updated)”

  1. This is a cool script, we use roaming profiles so is there a way to reference a directory on a server to have it scan their profile directories?

    1. Thank you: by changing this path you can have it check any folder you like.
      $path = $env:APPDATA + “\Microsoft\teams\” + $folder

      I haven’t tried it on a directory server, but if you have a pattern I could help you write a dynamic code.

  2. Is it possible to update this with the New Teams?
    Believe theres a new cache location and maybe even start process location.

  3. Hi, I get an error message when I run your script:

    Clear-TeamsCache
    Do you want to delete the Teams Cache (Y/N)?: y
    Stopping Teams Process
    Get-Process : Cannot find a process with the name “Teams”. Verify the process name and call the cmdlet again.
    At line:43 char:13
    + Get-Process -ProcessName Teams | Stop-Process -Force
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Teams:String) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

    Teams Process Sucessfully Stopped
    Clearing Teams Disk Cache
    Cleanup Complete… Launching Teams
    Start-Process : This command cannot be run due to the error: Systemet finner ikke angitt fil.
    At line:73 char:9
    + Start-Process -File “$($env:USERProfile)\AppData\Local\Micros …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

  4. ty

    think ill use but need it to delete the whole teams folder which is what we do at our company

    but the restart doesnt work. we dont have an update file after

  5. This is interesting! It automatically closes and opens the teams application after clearing the cache. This is quite impressive!

    1. Indeed, this line does so
      Get-Process -ProcessName Teams | Stop-Process -Force
      The Get-Process finds the process with the name “Teams” pipes it to the Stop-Process command.
      Start-Process -File "$($env:USERProfile)\AppData\Local\Microsoft\Teams\Update.exe" -ArgumentList '--processStart "Teams.exe"'
      Here it starts the Process again.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.