Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Purge Old IIS Log Files
- #
- # http://goo.gl/CrcSH7
- Param (
- # Files History Depth in Days
- [int]$Period = 10 ,
- # Purge this catalog
- [String]$PATH = "C:\inetpub\logs\LogFiles" ,
- # Include subdirectories
- [bool]$recurse = $true
- )
- filter Get-OldFiles
- {
- if
- (($_.Attributes -ne "Directory") `
- -and `
- (([DateTime]::Now.Subtract($_.CreationTime)).Days -gt $Period))
- {return $_ }
- }
- if ($recurse)
- {dir -path $PATH -recurse | Get-OldFiles -Period $Period | Remove-Item -recurse -force}
- else
- {dir -path $PATH | Get-OldFiles -Period $Period | Remove-Item -force}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement