Clear cache, cookies and history from IE and Chrome

  • 9 October 2020
  • 0 replies
  • 108 views

Figured it might be good to clear caches and cookies with a Worklet. Found this script fo target IE, Chrome and Chromimum directories together, and lets you define how old of data you’d like to remove by defining $DaysToDelete. This is written to be run manually. I’m repurposing this script from a script I found online because I’m jealous of the Yeti tumblers and this also seems like a good worklet to have (scanned this script with my sales eyes and it looks legit):


Evaluation


exit 0

Remediation:


$DaysToDelete = 1 ## Set this to the number of days to keep data on the device

$temporaryIEDir = "C:\users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" ## Remove all files and folders in user's Temporary Internet Files.
$cachesDir = "C:\Users\*\AppData\Local\Microsoft\Windows\Caches" ## Remove all IE caches.
$cookiesDir = "C:\Documents and Settings\*\Cookies\*" ## Delets all cookies.
$locSetDir = "C:\Documents and Settings\*\Local Settings\Temp\*" ## Delets all local settings temp
$locSetIEDir = "C:\Documents and Settings\*\Local Settings\Temporary Internet Files\*" ## Delets all local settings IE temp
$locSetHisDir = "C:\Documents and Settings\*\Local Settings\History\*" ## Delets all local settings history

Get-ChildItem $temporaryIEDir, $cachesDir, $cookiesDir, $locSetDir, $locSetIEDir, $locSetHisDir -Recurse -Force -Verbose -ErrorAction SilentlyContinue | Where-Object { ($_.CreationTime -lt $(Get-Date).AddDays(-$DaysToDelete)) } | remove-item -force -Verbose -recurse -ErrorAction SilentlyContinue

$DaysToDelete = 7

$crLauncherDir = "C:\Documents and Settings\%USERNAME%\Local Settings\Application Data\Chromium\User Data\Default"
$chromeDir = "C:\Users\*\AppData\Local\Google\Chrome\User Data\Default"
$chromeSetDir = "C:\Users\*\Local Settings\Application Data\Google\Chrome\User Data\Default"

$Items = @("*Archived History*", "*Cache*", "*Cookies*", "*History*", "*Login Data*", "*Top Sites*", "*Visited Links*", "*Web Data*")

$items | ForEach-Object {
$item = $_
Get-ChildItem $crLauncherDir, $chromeDir, $chromeSetDir -Recurse -Force -ErrorAction SilentlyContinue |
Where-Object { ($_.CreationTime -lt $(Get-Date).AddDays(-$DaysToDelete)) -and $_ -like $item} | ForEach-Object -Process { Remove-Item $_ -force -Verbose -recurse -ErrorAction SilentlyContinue }
}

0 replies

Be the first to reply!

Reply