major update to override Write-Output func

This commit is contained in:
2023-10-05 13:11:38 -04:00
parent 31a06a9206
commit bbb4884818
52 changed files with 377 additions and 378 deletions
+4 -4
View File
@@ -3,12 +3,12 @@
If ( $OlderThanDays -is [int] ) {
If ( Test-Path $Path ) {
LogMsg "Deleting all items older than ${OlderThanDays} days in ""${Path}"""
Write-Output "Deleting all items older than ${OlderThanDays} days in ""${Path}"""
$files = Get-ChildItem $Path | Where { !$_.PSIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-${OlderThanDays}) }
Foreach ( $f in $files ) {
$msg = "Deleting {0}" -f $f.FullName ; LogMsg $msg
$msg = "Deleting {0}" -f $f.FullName ; Write-Output $msg
Try { Remove-Item $f -Force | Out-Null }
Catch { LogErr $_.Exception.Message }
}
} Else { LogMsg "Path does not exist: ""${Path}""" }
} Else { LogMsg "The value entered for ""OlderThanDays"" is not an integer" }
} Else { Write-Output "Path does not exist: ""${Path}""" }
} Else { Write-Output "The value entered for ""OlderThanDays"" is not an integer" }