diff --git a/ClearBrowserCaches.exe b/ClearBrowserCaches.exe new file mode 100644 index 0000000..7303d49 Binary files /dev/null and b/ClearBrowserCaches.exe differ diff --git a/ClearBrowserCaches.ps1 b/ClearBrowserCaches.ps1 new file mode 100644 index 0000000..57081bd --- /dev/null +++ b/ClearBrowserCaches.ps1 @@ -0,0 +1,51 @@ +#Write-Host -ForegroundColor Green "SECTION 1: Getting the list of users" +#Write-Host -ForegroundColor yellow "Exporting the list of users to c:\users\%username%\users.csv" +# List the users in c:\users and export to the local profile for calling later +dir C:\Users | select Name | Export-Csv -Path C:\users\$env:USERNAME\users.csv -NoTypeInformation +$list=Test-Path C:\users\$env:USERNAME\users.csv +"" +#Write-Host -ForegroundColor Green "SECTION 2: Beginning Script..." +if ($list) { + #Clear Mozilla Firefox Cache + #Write-Host -ForegroundColor Green "SECTION 3: Clearing Mozilla Firefox Caches" + Write-Host -ForegroundColor cyan + Import-CSV -Path C:\users\$env:USERNAME\users.csv -Header Name | foreach { + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\* -Recurse -Force -EA SilentlyContinue + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\*.* -Recurse -Force -EA SilentlyContinue + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache2\entries\*.* -Recurse -Force -EA SilentlyContinue + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\thumbnails\* -Recurse -Force -EA SilentlyContinue + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cookies.sqlite -Recurse -Force -EA SilentlyContinue + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\webappsstore.sqlite -Recurse -Force -EA SilentlyContinue + Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\chromeappsstore.sqlite -Recurse -Force -EA SilentlyContinue + } + Write-Host -ForegroundColor yellow "Mozilla caches cleared" + #Write-Host -ForegroundColor Green "SECTION 4: Clearing Google Chrome Caches" + Write-Host -ForegroundColor cyan + Import-CSV -Path C:\users\$env:USERNAME\users.csv -Header Name | foreach { + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -EA SilentlyContinue +Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cache2\entries\*" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cookies" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Media Cache" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cookies-Journal" -Recurse -Force -EA SilentlyContinue + # Comment out the following line to remove the Chrome Write Font Cache too. + # Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\ChromeDWriteFontCache" -Recurse -Force -EA SilentlyContinue -Verbose + } + + Write-Host -ForegroundColor yellow "Google Chrome caches cleared" + # Clear Internet Explorer + #Write-Host -ForegroundColor Green "SECTION 5: Clearing Internet Explorer Caches" + Write-Host -ForegroundColor cyan + Import-CSV -Path C:\users\$env:USERNAME\users.csv | foreach { + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Microsoft\Windows\WER\*" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Temp\*" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\Windows\Temp\*" -Recurse -Force -EA SilentlyContinue + Remove-Item -path "C:\`$recycle.bin\" -Recurse -Force -EA SilentlyContinue + } + Remove-Item -Path C:\users\$env:USERNAME\users.csv -Force + Write-Host -ForegroundColor yellow "IE caches cleared" + Write-Host -ForegroundColor Green "Nettoyage OK" + } else { + Write-Host -ForegroundColor Yellow "Session Cancelled" + Exit + } \ No newline at end of file diff --git a/README.md b/README.md index 65b5ebf..930dc54 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# ClearBrowsersCaches - +# ClearBrowserCaches +PowerShell tool to clear all browsers caches for all users