This commit is contained in:
2020-08-18 16:20:20 -04:00
parent 98fb3928c5
commit cb110b354d
26 changed files with 225 additions and 201 deletions
+13
View File
@@ -0,0 +1,13 @@
[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 }
}