Clear Temp Files
Category: System Maintenance
Deletes contents of the user and Windows temp directories to reclaim disk space and fix temp file conflicts.
$tempPaths = @("$env:TEMP", "$env:windir\Temp")
foreach ($path in $tempPaths) {
Write-Host "Clearing temp files from: $path" -ForegroundColor Yellow
try {
Remove-Item "$path\*" -Recurse -Force -ErrorAction Stop
Write-Host "Cleared: $path" -ForegroundColor Green
} catch {
Write-Host "Failed to clear $path: $_" -ForegroundColor Red
}
}
Comments
Log in to leave a comment.