├── Clear_Browser_Caches └── README.md /Clear_Browser_Caches: -------------------------------------------------------------------------------- 1 | Write-Host -ForegroundColor yellow "#######################################################" 2 | "" 3 | Write-Host -ForegroundColor Green "Powershell commands to delete cache & cookies in Firefox, Chrome & IE browsers" 4 | Write-Host -ForegroundColor Green "By Lee Bhogal, Paradise Computing Ltd - June 2014" 5 | Write-Host -ForegroundColor Green "VERSION: 2" 6 | "" 7 | Write-Host -ForegroundColor yellow "#######################################################" 8 | "" 9 | Write-Host -ForegroundColor Green "CHANGE_LOG: 10 | v2.4: - Resolved *.default issue, issue was with the file path name not with *.default, but issue resolved 11 | v2.3: - Added Cache2 to Mozilla directories but found that *.default is not working 12 | v2.2: - Added Cyan colour to verbose output 13 | v2.1: - Added the location 'C:\Windows\Temp\*' and 'C:\`$recycle.bin\' 14 | v2: - Changed the retrieval of user list to dir the c:\users folder and export to csv 15 | v1: - Compiled script" 16 | "" 17 | Write-Host -ForegroundColor yellow "#######################################################" 18 | "" 19 | ######################### 20 | "-------------------" 21 | Write-Host -ForegroundColor Green "SECTION 1: Getting the list of users" 22 | "-------------------" 23 | # Write Information to the screen 24 | Write-Host -ForegroundColor yellow "Exporting the list of users to c:\users\%username%\users.csv" 25 | # List the users in c:\users and export to the local profile for calling later 26 | dir C:\Users | select Name | Export-Csv -Path C:\users\$env:USERNAME\users.csv -NoTypeInformation 27 | $list=Test-Path C:\users\$env:USERNAME\users.csv 28 | "" 29 | ######################### 30 | "-------------------" 31 | Write-Host -ForegroundColor Green "SECTION 2: Beginning Script..." 32 | "-------------------" 33 | if ($list) { 34 | "-------------------" 35 | #Clear Mozilla Firefox Cache 36 | Write-Host -ForegroundColor Green "SECTION 3: Clearing Mozilla Firefox Caches" 37 | "-------------------" 38 | Write-Host -ForegroundColor yellow "Clearing Mozilla caches" 39 | Write-Host -ForegroundColor cyan 40 | Import-CSV -Path C:\users\$env:USERNAME\users.csv -Header Name | foreach { 41 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\* -Recurse -Force -EA SilentlyContinue -Verbose 42 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\*.* -Recurse -Force -EA SilentlyContinue -Verbose 43 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache2\entries\*.* -Recurse -Force -EA SilentlyContinue -Verbose 44 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\thumbnails\* -Recurse -Force -EA SilentlyContinue -Verbose 45 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cookies.sqlite -Recurse -Force -EA SilentlyContinue -Verbose 46 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\webappsstore.sqlite -Recurse -Force -EA SilentlyContinue -Verbose 47 | Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\chromeappsstore.sqlite -Recurse -Force -EA SilentlyContinue -Verbose 48 | } 49 | Write-Host -ForegroundColor yellow "Clearing Mozilla caches" 50 | Write-Host -ForegroundColor yellow "Done..." 51 | "" 52 | "-------------------" 53 | # Clear Google Chrome 54 | Write-Host -ForegroundColor Green "SECTION 4: Clearing Google Chrome Caches" 55 | "-------------------" 56 | Write-Host -ForegroundColor yellow "Clearing Google caches" 57 | Write-Host -ForegroundColor cyan 58 | Import-CSV -Path C:\users\$env:USERNAME\users.csv -Header Name | foreach { 59 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -EA SilentlyContinue -Verbose 60 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cache2\entries\*" -Recurse -Force -EA SilentlyContinue -Verbose 61 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cookies" -Recurse -Force -EA SilentlyContinue -Verbose 62 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Media Cache" -Recurse -Force -EA SilentlyContinue -Verbose 63 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cookies-Journal" -Recurse -Force -EA SilentlyContinue -Verbose 64 | # Comment out the following line to remove the Chrome Write Font Cache too. 65 | # Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\ChromeDWriteFontCache" -Recurse -Force -EA SilentlyContinue -Verbose 66 | } 67 | 68 | Write-Host -ForegroundColor yellow "Done..." 69 | "" 70 | "-------------------" 71 | # Clear Internet Explorer 72 | Write-Host -ForegroundColor Green "SECTION 5: Clearing Internet Explorer Caches" 73 | "-------------------" 74 | Write-Host -ForegroundColor yellow "Clearing Google caches" 75 | Write-Host -ForegroundColor cyan 76 | Import-CSV -Path C:\users\$env:USERNAME\users.csv | foreach { 77 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Recurse -Force -EA SilentlyContinue -Verbose 78 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Microsoft\Windows\WER\*" -Recurse -Force -EA SilentlyContinue -Verbose 79 | Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Temp\*" -Recurse -Force -EA SilentlyContinue -Verbose 80 | Remove-Item -path "C:\Windows\Temp\*" -Recurse -Force -EA SilentlyContinue -Verbose 81 | Remove-Item -path "C:\`$recycle.bin\" -Recurse -Force -EA SilentlyContinue -Verbose 82 | } 83 | 84 | Write-Host -ForegroundColor yellow "Done..." 85 | "" 86 | Write-Host -ForegroundColor Green "All Tasks Done!" 87 | } else { 88 | Write-Host -ForegroundColor Yellow "Session Cancelled" 89 | Exit 90 | } 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Powershell 2 | Powershell scripts by Lemtek 3 | --------------------------------------------------------------------------------