Cleanup IIS Logs AutoMagically

First head over to the Microsoft Script Gallery and grab deleteold.ps1 by Jaap Brasser.

I tend to copy scripts to c:\scripts on systems so I copied deleteold.ps1 there and created two new batch files there as well.

The first was used to launch the powershell script with switches that will delete all files in the IIS Logs directory older than 90 days and append to a log of all actions taken.

IISLogsCleanUp.bat :

The second batch file registers a task that runs this script weekly. Right click this batch and run as administrator and IIS logs will no longer be a thorn in your side.

IISLogCleanUpTaskReg.bat :

 

 

As usual, customize as needed! Next on my list is for this repetitive task is creating a powershell remoting script to copy these files to remote servers and execute the task register command.

Leave a Comment