PS-Commands/Scripts/Clear-env-Temp-14-days.ps1

8 lines
232 B
PowerShell
Raw Normal View History

2023-08-17 13:45:36 +03:00
$ls = Get-Item $env:TEMP\*.tmp # or your path and file extension
$date = (Get-Date).AddDays(-14)
foreach ($l in $ls) {
if ($l.LastWriteTime -le $date) {
$l.FullName
Remove-Item $l.FullName -Recurse
}
}