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 you delete the whole App folder. This will also delete your custom backgrounds, the script let you choose which folders to remove.
To see the folders you delete; open the Run dialog (Win+R). Enter %appdata%\Microsoft\Teams, and click OK. The script has an array to choose which folder to delete, you can change the array to fit your needs.
Check my repo on GitHub, to get the latest updates in case I create some new options or change the standard folders. Use this script to learn more
This is interesting! It automatically closes and opens the teams application after clearing the cache. This is quite impressive!
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.