Avatar of Scotch Tech
Scotch Tech
Flag 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.
ExchangePowershell

Avatar of undefined
Last Comment
Scotch Tech

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Dent

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy