major update

This commit is contained in:
2021-05-24 14:05:59 -04:00
parent 1d882a7ddc
commit e767d39d85
39 changed files with 43 additions and 2272 deletions
-31
View File
@@ -1,31 +0,0 @@
<#
.SYNOPSIS
Remove files older than the specified number of days.
.DESCRIPTION
This script will delete all files in a directory which are older than the specified number of days.
It will not search recursively for files and will only look in the directory specified.
.PARAMETER
-Path
This is the directory to search for old files
.PARAMETER
-OlderThan
This is the number of days that limits the files that are deleted.
Anything newer than the value specified here will be retained, while anything older than the value specified here will be deleted.
.EXAMPLE
Remove-OldFiles -Path "C:\Windows\TEMP" -OlderThan 30
This will remove all files in C:\Windows\TEMP that are older than 30 days
#>
Param(
[string]$Path="C:\Users\dyoder\Desktop",
[int]$OlderThan=7
)
If ( Test-Path $Path ) {
$files = Get-ChildItem $Path | Where { !$_.PSIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-${OlderThan}) }
foreach ( $f in $files ) { write-host $f.FullName }
} Else { Write-Host "The path does not exist: ${Path}" }