Created
June 14, 2023 21:56
-
-
Save derekschartung/49a224c087f344fd46f0213ba3838ce0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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