Skip to content

Instantly share code, notes, and snippets.

@derekschartung
Created June 14, 2023 21:56
Show Gist options
  • Select an option

  • Save derekschartung/49a224c087f344fd46f0213ba3838ce0 to your computer and use it in GitHub Desktop.

Select an option

Save derekschartung/49a224c087f344fd46f0213ba3838ce0 to your computer and use it in GitHub Desktop.
# Define some variables
$UserData = "$($env:LOCALAPPDATA)\Google\Chrome\User Data"
$Folders = Get-ChildItem $UserData | Where-Object{ $_.PSIsContainer -and $_.Name -eq "Default" -or $_.Name -like "Profile*"}
$FoldersFullPath = $Folders.FullName
# Nuke Chrome from orbit
if ($Null -ne (get-process 'chrome' -ErrorAction SilentlyContinue)){
stop-process -ProcessName 'chrome'
Start-Sleep -Seconds 5
}
# Recursively delete profile folders and files
$FoldersFullPath | ForEach-Object {
if (Test-Path -Path $_){
Remove-Item -Recurse -Path $_
}
}
# Remove the local state folder if present
if (Test-Path -Path "$UserData\Local state"){
Remove-Item -Path "$UserData\Local state"
}
# Start Chrome again
start chrome
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment