diff --git a/Remove-OldFiles.ps1 b/Remove-OldFiles.ps1 index a4e07b6..4ccb9c5 100644 --- a/Remove-OldFiles.ps1 +++ b/Remove-OldFiles.ps1 @@ -4,7 +4,7 @@ If ( $OlderThanDays -is [int] ) { If ( Test-Path $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}) } + $files = Get-ChildItem $Path | Where-Object { !$_.PSIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays(-${OlderThanDays}) } Foreach ( $f in $files ) { $msg = "Deleting {0}" -f $f.FullName ; Write-Output $msg Try { Remove-Item $f -Force | Out-Null }