My PowerShell

Windows Powershell scripts, examples, tips, docs …

Delete IIS logs after certain number of days

Especially on Exchange servers there are a lot of OWA logs which can be found in “C:\inetpub\logs\LogFiles\W3SVC1″.

This small Powershell script can be useful, it will delete IIS Log files older than 60 days

get-childitem -Path C:\inetpub\logs\LogFiles\W3SVC1 -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-60)} | Foreach-Object { del $_.FullName }

Tagged as:

Leave a Response