Skip to content

Instantly share code, notes, and snippets.

@h3ct0rjs
Created April 22, 2021 02:24
Show Gist options
  • Save h3ct0rjs/d6c3f2baa6cf2bbdabbf62ce5c86c4b6 to your computer and use it in GitHub Desktop.
Save h3ct0rjs/d6c3f2baa6cf2bbdabbf62ce5c86c4b6 to your computer and use it in GitHub Desktop.
Write-Host "Are you sure you want to delete Teams Cache (Y/N)?" -ForegroundColor Yellow -NoNewLine
$challenge = Read-Host
$challenge = $challenge.ToUpper()
if ($challenge -eq "Y"){
try{
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Stopping Teams Processes if running" -ForegroundColor Cyan
Get-Process -ProcessName Teams -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 3
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Teams Processes Sucessfully Stopped" -ForegroundColor Green
}catch{
echo $_
}
try{
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Clearing Teams Disk Cache" -ForegroundColor Cyan
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\application cache\cache" -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\databases" -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\cache" -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\gpucache" -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Indexeddb" -Recurse -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false -Recurse
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Local Storage" -Recurse -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false -Recurse
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\tmp" -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Teams Disk Cache Cleaned" -ForegroundColor Green
}catch{
echo $_
}
try{
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Stopping Chrome Processes if running" -ForegroundColor Cyan
Get-Process -ProcessName Chrome -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 3
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Chrome Processes Sucessfully Stopped" -ForegroundColor Green
}catch{
echo $_
}
try{
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Clearing Chrome Cache" -ForegroundColor Cyan
Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Cache" | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Cookies" -File -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Get-ChildItem -Path $env:LOCALAPPDATA"\Google\Chrome\User Data\Default\Web Data" -File -ErrorAction SilentlyContinue | Remove-Item -Confirm:$false
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Chrome Cleaned" -ForegroundColor Green
}catch{
echo $_
}
try{
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Stopping IE Processes if running" -ForegroundColor Cyan
Get-Process -ProcessName MicrosoftEdge -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process -ProcessName IExplore -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Internet Explorer and Edge Processes Sucessfully Stopped" -ForegroundColor Green
}catch{
echo $_
}
try{
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Clearing IE Cache" -ForegroundColor Cyan
RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 8
RunDll32.exe InetCpl.cpl, ClearMyTracksByProcess 2
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] IE and Edge Cleaned" -ForegroundColor Green
}catch{
echo $_
}
Write-Host "[$((Get-Date).ToString("HH:mm:ss"))] Cleanup Complete... Launching Teams" -ForegroundColor Cyan
Start-Process -FilePath $env:LOCALAPPDATA\Microsoft\Teams\current\Teams.exe
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment