Hi Team,
Is there any way to delete Cookies and Caches from Edge and Chrome?
Hi Team,
Is there any way to delete Cookies and Caches from Edge and Chrome?
Hey Jai,
Below is something you can try:
Since I don’t want to clear my Chrome cache, I haven’t tested this, but you can try
ps chrome -ErrorAction SilentlyContinue | kill -PassThru
Start-Sleep -Seconds 5
#Main Section
$Items = @(‘Archived History’,
‘Cache*’,
‘Cookies’,
‘History’,
‘Login Data’,
‘Top Sites’,
‘Visited Links’,
‘Web Data’)
$Folder = “$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default”
$Items | % {
if (Test-Path “$Folder$<em>") {
Remove-Item "$Folder$</em> ”-Recurse -Confirm:$false -Force
}
}
In addition, I discovered this MS article about Microsoft Edge and tested the script below; mine cleared successfully. Please test and attempt as appropriate.
# kill process
Stop-Process -Name msedge -Force -ErrorAction SilentlyContinue
# Get profiles
$profiles = Get-ChildItem -Path "C:\Users" -Directory
# Loop through each user profile
foreach ($profile in $profiles) {
$cachePath = Join-Path -Path $profile.FullName -ChildPath "AppData\Local\Microsoft\Edge\User Data\Default\Cache\Cache_Data*"
# Check if the cache path exists
if (Test-Path $cachePath) {
# Clear cache data for the current user profile
Remove-Item -Path $cachePath -Force -Recurse
Write-Host "Cache data cleared for user profile: $($profile.Name)"
}
else {
Write-Host "Cache data not found for user profile: $($profile.Name)"
}
}