Delete IIS Logs Automatically

By | 2022-08-25

On web servers, and Exchange OWA servers especially, 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 }

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.