Link to home
Start Free TrialLog in
Avatar of Scotch Tech
Scotch TechFlag for United States of America

asked on

Exchange 2013 - Scheduled task to clear IIS logs

I've seen several different ways to do this. I just want a simple script to clear out logs older than 30days to run daily.

I don't see an option with the Remove-Item cmdlet.
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scotch Tech

ASKER

awesome, I actually found this as well and tested:

Get-ChildItem -Path "C:\inetpub\logs\LogFiles\W3SVC1" -File | Where CreationTime -lt  (Get-Date).AddDays(-30)  | Remove-Item -Force