Chrome en IE cache opschonen

De cache folders van Chrome en IE kunnen wel eens flink vollopen. Met het onderstaande powershell script zijn ze eenvoudig op te schonen.

$DaysToDelete = 1
 $tempIEDir = "C:\users*\AppData\Local\Microsoft\Windows\Temporary Internet Files*" ## Delete all files and folders in user Temporary Internet Files. 
 $cacheDir = "C:\Users*\AppData\Local\Microsoft\Windows\Caches"  ## Remove all IE cachs. 
 $cookieDir = "C:\Documents and Settings*\Cookies*" ## Delete all cookies. 
 $locSetDir = "C:\Documents and Settings*\Local Settings\Temp*"  ## Delete all local settings temp 
 $locSetIEDir = "C:\Documents and Settings*\Local Settings\Temporary Internet Files*"   ## Delete all local settings IE temp 
 $locSetHisDir = "C:\Documents and Settings*\Local Settings\History*"  ## Delete all local settings history
 Get-ChildItem $tempIEDir, $cacheDir, $cookieDir, $locSetDir, $locSetIEDir, $locSetHisDir -Recurse -Force -Verbose -ErrorAction SilentlyContinue | Where-Object { ($_.CreationTime -lt $(Get-Date).AddDays(-$DaysToDelete)) } | remove-item -force -Verbose -recurse -ErrorAction SilentlyContinue
 $DaysToDelete = 1
 $chromiumLaunchDir = "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 $chromiumLaunchDir, $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 }
 }