Cleanup Edge Cache, Dump Files, Recycle Bins

Modified on Tue, 16 Jun at 1:07 PM

Clear Edge Cache for all users:

# Stop Edge if any rogue background processes are running
Stop-Process -Name "msedge" -Force -ErrorAction SilentlyContinue

# Target Cache and Service Worker directories for all profiles
$UserProfiles = Get-ChildItem "C:\Users" -Directory | Where-Object { $_.Name -notmatch "Public|Default" }

foreach ($Profile in $UserProfiles) {
    $EdgeDefaultPath = "$($Profile.FullName)\AppData\Local\Microsoft\Edge\User Data\Default"
    
    if (Test-Path $EdgeDefaultPath) {
        Write-Host "Cleaning Edge data for $($Profile.Name)..." -ForegroundColor Cyan
        
        # Target the specific heavy folders from your WizTree image
        $Targets = @("Cache", "Code Cache", "Service Worker")
        foreach ($Target in $Targets) {
            $FullPath = Join-Path $EdgeDefaultPath $Target
            if (Test-Path $FullPath) {
                Remove-Item -Path "$FullPath\*" -Recurse -Force -ErrorAction SilentlyContinue
            }
        }
    }
}


Disable Crash Dumps for all users

New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value 0 -PropertyType DWORD -Force


Delete existing dump files

Get-ChildItem -Path "C:\Users\*\AppData\Local\CrashDumps" -Filter "*.dmp" -ErrorAction SilentlyContinue | Remove-Item -Force


Empty recycle bin for all users

Remove-Item -Path 'C:\$Recycle.Bin\*' -Force -Recurse

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article