Library / Windows endpoint

WIN-019 · Script

Clear Teams and Outlook Cache

Clears cached data for classic Teams, new Teams and Outlook in user profiles, without touching mailbox data files.

Version 1.0.0Language PowerShellUpdated November 2026

What it does

A common first fix for Teams that will not load, shows old data, or fails to sign in, and for Outlook attachment and preview problems. Works per user profile, so it can run as SYSTEM for every profile on a shared device or for selected users.

What is cleared: ClassicTeams Cache folders inside AppData\Roaming\Microsoft\Teams (Cache, Code Cache, GPUCache, blob_storage, databases, IndexedDB, Local Storage, tmp, application cache, Service Worker cache). Settings files are kept.

  • NewTeams: The contents of AppData\Local\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\

Microsoft\MSTeams, which is the cache reset method for new Teams. Users may need to sign in to Teams again.

  • Outlook: The Outlook secure temporary attachment folder (INetCache\Content.Outlook)

and the web view cache folders of the new Outlook app (Olk\EBWebView).

What is never deleted: OST, PST and NST data files, the Outlook RoamCache folder (AutoComplete and other cached settings), Offline Address Books, signatures and profiles.

Report mode (default) shows each cache folder and its size. Fix mode deletes the cache contents. Files in use cannot be removed, so an app that is running for that user is skipped in Fix mode unless -CloseApps is set, which closes Teams and Outlook for those users first (unsaved drafts in Outlook may be lost). Runs silently. No prompts.

Requirements

Windows PowerShell 5.1+, run as SYSTEM or local admin (or as the user for their own profile)

How to run it

  • Run as: SYSTEM or a local administrator
  • Run from: any RMM or MDM, Intune, a Group Policy startup script, a scheduled task, or an elevated PowerShell window
  • Script type: PowerShell, 64-bit
  • User interaction: none; the script never prompts
  • Timeout: 10 minutes (30 for Windows Update installs)

Settings

NameWhat it doesOptionsDefault
ModeReport (default) = show cache folders and sizes. Fix = delete the cache contents.Report, FixReport
TargetWhich caches to clear: ClassicTeams, NewTeams, Outlook. Default all three.ClassicTeams, NewTeams, Outlook
UserNameOnly these profile folder names, for example "jsmith","akhan". Default every user profile.(none)
CloseAppsFix mode only: close Teams and Outlook for the selected users before clearing.False

Exit codes

  • 0 = Report done, or caches cleared
  • 1 = Some caches skipped because the app was running, or some files could not be removed
  • 2 = Script error

Testing steps

  1. Run it first with the mode set to Report on one test device. Nothing is changed in that mode.
  2. Read the log and confirm the planned changes are what you expect.
  3. Run your chosen settings on the same test target and confirm the result.
  4. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  5. Roll out to a small group next, then everyone.

Rollback steps

Cache files are rebuilt automatically the next time Teams or Outlook starts. Users may need to sign in to Teams again. Mailbox data files (OST, PST) and RoamCache are never deleted.

Version and change log

VersionDateChanges
1.0.0November 2026First release.