Skip to content

Instantly share code, notes, and snippets.

@jpelton-stroud
Last active August 3, 2021 14:36
Show Gist options
  • Save jpelton-stroud/be222c1a12948f44a8f5c0195d9a1773 to your computer and use it in GitHub Desktop.
Save jpelton-stroud/be222c1a12948f44a8f5c0195d9a1773 to your computer and use it in GitHub Desktop.
Chrome cache reset
# Chrome app location
$App = "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
# Chrome user data location
$UserFolder = "${env:LOCALAPPDATA}\Google\Chrome\User Data\Default"
# Chrome datastores
$CacheData = @(
'Cookies'
'Web Data'
'Cache\*'
'Sessions\*'
'Session Storage\*'
'Service Worker\*'
'Local Storage\*'
'IndexedDB\*'
)
# Arguments to pass to chrome on launch
$LaunchArgs = @(
# Prompt user to sign into chrome on relaunch
'https://accounts.google.com/signin/chrome/sync/identifier?flowName=GlifDesktopChromeSync'
'--disable-gpu'
'--disable-software-rasterizer'
)
# Find & terminate all Chrome processes
Get-Process -Name 'chrome' | Stop-Process
# Wait for all processes to terminate
Get-Process | Where-Object {$_.HasExited}
# Clear target cached data
$CacheData | ForEach-Object {
if (Test-Path "$UserFolder\$_") {
Remove-Item "$UserFolder\$_" -Recurse -Verbose
}
}
# Restart Chrome
Start-Process $App -ArgumentList $LaunchArgs -WindowStyle Maximized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment