This commit is contained in:
2020-08-14 14:19:37 -04:00
parent d18f8dad97
commit f2b358d8dd
24 changed files with 253 additions and 180 deletions
-15
View File
@@ -1,15 +0,0 @@
[CmdletBinding()]
param(
[int]$OlderThan=7
)
## Create a new timespan to compare with last write date of the target directory
$timedelta = New-TimeSpan -Days $OlderThan
## Remove all files and directories
Foreach ( $item in (Get-ChildItem -Path "${Env:WinDir}\TEMP") ) {
## If it's older than the number of days specified, recursively delete the directory
If ( $item.LastWriteTime -lt ((Get-Date) - $timedelta) ) { Remove-Item $item.FullName -Recurse -ErrorAction SilentlyContinue -Force }
}