Blog Post

ITOps Talk Blog
1 MIN READ

PowerShell Basics: How to Delete Microsoft Teams Cache for All Users

AnthonyBartolo's avatar
Jul 14, 2020

Sometimes there is a need to delete Microsoft Teams cache to quicken the adoption of an in-band policy change or simply troubleshoot an issue. The challenge here is that the cache for Microsoft Teams is in multiple directories. This can be done manually but would result in a slow and tedious process. Again, we turn to PowerShell to automate this process and this time it's a one-liner that addresses this opportunity. 

 

Get-ChildItem "C:\Users\*\AppData\Roaming\Microsoft\Teams\*" -directory | Where name -in ('application cache','blob storage','databases','GPUcache','IndexedDB','Local Storage','tmp') | ForEach{Remove-Item $_.FullName -Recurse -Force -WhatIf}

 

The end of the one-liner calls a -WhatIf which can be removed to enforce deletion.

 

As always, please share your comments below on bettering the above script or any questions you may have.

 

Updated May 04, 2021
Version 9.0

33 Comments

  • pkwdr's avatar
    pkwdr
    Copper Contributor

    As get-childitem piped to get-childitem does not work in our Infra, i changed the Script to take only the current user:

    Get-ChildItem -Path "C:\Users\$env:UserName\AppData\Roaming\Microsoft\Teams" -Directory|Where{$_ -in ('Cache','databases','blob_storage','IndexedDB','')}|ForEach{Remove-Item $_.FullName -Recurse -Force}

    So every user would be able to kill his own cache only.

     

    Regards

    Pawel

  • BlackV's avatar
    BlackV
    Brass Contributor

    Do you need both get-childitems?

    Why not just

     

    Get-ChildItem "C:\Users\*\AppData\Roaming\Microsoft\Teams" -Directory| xxxx

    instead?