After a couple of weeks of running an SCCM server, you may get the C:\ drive full. What are the best practices to save disk space on an SCCM server? The first thing we check is how much space is filled by SCCM IIS log files. Usually, it takes a couple of GB on the drive. It’s an absolute must to implement solutions to delete SCCM IIS logs files from your primary server.

The SCCM IIS logs files are usually in C:\Inetpub\Logs\LogFiles and are increasing at a rapid pace. In my lab environment with 50 clients, it’s growing at about 1MB per day. Not much… but on an SCCM site, I’m actually managing with a couple of thousand clients, it grows 150 MB a day. It could fill up a drive pretty quickly.

SCCM IIS Log Files

There are numerous ways to manage SCCM IIS log files :

  1. Delete the logs manually or use a scheduled task
  2. Use a Powershell script
  3. Disable the IIS Logs completely
  4. Enable Folder Compression
  5. Use the IISLogCleaner tool

Delete SCCM IIS Logs Files Manually

SCCM IIS log files are mainly for troubleshooting and reviewing security. If neither are of immediate interest to you, then you can turn off logging or write a script to delete them. An easy way to do this is by using the Foreach command in a Windows Server Task Scheduler. We will delete all IIS log files that are older than 30 days :

  • On your SCCM server, start Task Scheduler
  • On the right pane, select Create Basic Task
SCCM IIS Log Files
  • On the Create Basic Task Wizard, name your task and click Next
SCCM IIS Log Files
  • On the Trigger section, select Weekly
SCCM IIS Log Files
  • Select the desired schedule. We select to run every Sunday
SCCM IIS Log Files
  • In the Action section, select Start a program
SCCM IIS Log Files
  • In the Start a Program section, entrer the following command : Forfiles.exe -p C:\inetpub\logs\LogFiles\W3SVC1 -m *.log -d -30 -c “Cmd.exe /C del @path\”
  • You can change the number of days if desired (30)
SCCM IIS Log Files
  • It’s important to select Yes in the warning, it will split your command to fill the Add Argument section
SCCM IIS Log Files

You can test your job by running your job manually or wait for the schedule to trigger the task. After running you should have no file older than 30 days and should free some space from your drive.

Delete SCCM IIS Log Files using PowerShell or VBS Script

You can also delete SCCM IIS logs file using PowerShell or VBS script. Here are 3 scripts that work fine and which can also be used with a Configuration Item in order to run when your server is not compliant. Pick the one that fits your needs :

Disable IIS logging

If you really don’t care about keeping SCCM IIS logs files, you can disable it completely in IIS Manager or redirect the log files to another drive : (We do not recommend disabling it, it won’t hurt SCCM directly but you could be unable to run some report (IE : Distribution Point utilization) which are based on these files.)

  • Open IIS Manager
  • On the left pane, select your server
  • On the right pane, select Logging
  • In the Logging pane, click Disable in the Actions section
  • If you prefer to change the log file location, you can do it by typing the new location in the Directory box

Enable Folder Compression

Enabling folder compression won’t free up space but could help if you don’t want to delete the files (IIS log files compress to about 2% of their original size). You must be an administrator to perform this procedure :

  • Click the File Manager icon in the icon bar
  • Move to the folder containing IIS log files (by default, C:\inetpub\logs\LogFiles)
  • Right-click on the folder and click Properties
  • On the General tab of the Properties page, click Advanced
  • Click Compress contents to save disk space, and then click OK
SCCM IIS Log Files
  • Click Apply, and then select whether to compress the folder only, or the folder, its subfolders, and its files.
  • Click OK.

Verify that the folder contents are compressed. The name of the folder and the name of each file should be colored in blue, and the size of a compression file should be smaller.

IISLogCleaner executable

IISLogCleaner is a simple tool to enable a log retention policy for IIS. The tool runs in the background and cleans the IIS log folder automatically older than a maximum age. This is a third-party tool that is not supported by Microsoft.

  1. Download the executable
  2. Execute IISLogCleaner.exe
  3. Open the settings.txt file with a text editor to make configuration changes or right-click the IIS icon in the notification area, and then click Settings
  4. Right-click the IIS icon in the notifications area, and then click Paused to un-pause the application.
Comments (3)

Jan Vogel

11.25.2016 AT 07:27 AM
We actually have another W3SVC1 Folder (due to the WSUS installation), keep in mind to empty those log files as well 😉

Nicolas Moreno

11.24.2016 AT 05:31 AM
FYI There is a typo in the command. A backslash crept in between the -c and the "cmd.exe..." Forfiles.exe -p C:\inetpub\logs\LogFiles\W3SVC1 -m *.log -d -30 -c \"Cmd.exe /C del @path\" Should be Forfiles.exe -p C:\inetpub\logs\LogFiles\W3SVC1 -m *.log -d -30 -c "Cmd.exe /C del @path\"

Benoit Lecours

11.24.2016 AT 10:37 AM
You're right. I updated the blog post. Thanks for your input !