major update to override Write-Output func
This commit is contained in:
+4
-4
@@ -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" }
|
||||
Reference in New Issue
Block a user