Skip to content

Instantly share code, notes, and snippets.

@CanXploit
Created January 17, 2026 09:04
Show Gist options
  • Select an option

  • Save CanXploit/9e12d591ee115365b56fafb90c80d296 to your computer and use it in GitHub Desktop.

Select an option

Save CanXploit/9e12d591ee115365b56fafb90c80d296 to your computer and use it in GitHub Desktop.
PowerShell script to clean temporary files, Prefetch, Windows Update cache, and Recycle Bin safely
$Paths = @(
"$env:LOCALAPPDATA\Temp",
"$env:TEMP",
"C:\Windows\Prefetch",
"C:\Windows\SoftwareDistribution\Download",
"C:\Windows\Temp"
)
foreach ($path in $Paths) {
Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
Clear-RecycleBin -Force -ErrorAction SilentlyContinue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment