Cleanup the iis logs on a configmgr server

If you have installed a ConfigMgr on a server a few years ago there might be a lot of IIS log files stored on the C drive (if you used the default settings when installing the IIS). In the sample picture it’s been 246 days since the installation and each log file is about 8-20 MB depending on the traffic to the IIS server. In time this can become a problem.

Logfiles IIS

Copy the syntax below and paste it into an elevated command prompt and hit enter.

So now there is a new scheduled job created in Task Scheduler that clears the IIS log directory from files that are 30 days and older. The location where the log directory is located on the server is automatically found out by the PowerShell command.

This will free up some space on C: drive next Sunday at 01:00 or directly if you run the task manually. .

Cleanup Task

 

Have a nice day Johnny