We get this question a lot : C:\ drive gets full after a couple of week running SCCM, what are the best practices to save disk space on a SCCM server ? The first thing we propose is to delete SCCM IIS logs files. It’s an absolute must to implement a solution 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 in a site i’m actually managing with a couple thousand clients, it grows 150 MB a day. It could fill up a drive pretty quickly.
There are numerous ways to manage SCCM IIS log files :
- Delete the logs manually or using a schedule task
- Use a Powershell script
- Disable the IIS Logs completely
- Enable Folder Compression
Delete SCCM IIS Logs File Manually
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 pane, select Create Basic Task
- On the Create Basic Task Wizard, name your task and click Next
- On the Trigger section, select Weekly
- Select the desired schedule. We select to run every Sunday
- In the Action section, select Start a program
- 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)
- It’s important to select Yes in the warning, it will split your command to fill the Add Argument section
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.
PowerShell or VBS Script
You can also delete SCCM IIS logs file using PowerShell or VBS script. Here’s 3 scripts that works 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 on 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
- 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.
Founder of System Center Dudes. Based in Montreal, Canada, Senior Microsoft SCCM Consultant, 5 times Enterprise Mobility MVP. Working in the industry since 1999. His specialization is designing, deploying and configuring SCCM, mass deployment of Windows operating systems, Office 365 and Intunes deployments.