Configuration Manager – IIS Log Maintenance
The majority of SCCM administrators will have included a list of maintenance tasks for ensuring optimum performance of their environment. One area that often gets overlooked however is the maintenance of IIS logs. Logs are obviously useful for troubleshooting purposes, however do you really need to know what was happening say over 30 days ago. The truth is if there was an issue you probably would have spotted it very early on and dealt with it.
So how do you deal with log files within your IIS directory filling up your disks?. The answer can be to setup a configuration item and let SCCM take care of its own compliance.
Creating Your SCCM Server Device Collection
To start with you will need to create a Device Collection to deploy the Configuration Item and subsequent Baseline to. This can be achieved by creating a device collection using the following query;
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.ResourceNames in (Select ServerName FROM SMS_DistributionPointInfo)
Creating Your SCCM IIS Prune Logs Configuration Item
Once you have the device collection created and populated you can go on to create the Configuration Item to be used. To speed up this process I have exported the CI CAB for you to download, below are some screen shots of the manual creation process;
Create Configuration Item
Select Supported Platforms
In this section we will pick which operating systems are applicable for SCCM distribution points
Here we will create a new setting entry that will contain both the discovery and remediation scripts required
Here we will specify when to run the remediation script you created in the previous step
Now in order to apply the Configuration Item we will need to create a Configuration Baseline for the SCCM Server Device Collection.
Create a new Configuration Baseline
Set Evaluation Conditions
Here we will add the Configuration Baseline we created earlier;
Deploy the Configuration Baseline
Set your schedule and generate an alert if required..
Now sit back, relax and watch your good work take hold across your estate;
Below we have the before and after results of a distribution point running a low workload;
Before (Manual Run)
After (Manual Run)
When you have a large environment with thousands of clients you can clearly see the storage recovery benefits!.
The automated and manual scripts can be downloaded from the Microsoft Technet script gallery – https://gallery.technet.microsoft.com/IIS-Log-Maintenance-6f357306
A special thanks goes out to Johan Arwidmark for sharing this clean up script on his DeploymentResearch blog (http://deploymentresearch.com/Research/Post/563/A-little-bit-of-ConfigMgr-housekeeping).
Maurice has been working in the IT industry for the past 18 years and currently working in the role of Principal Consultant with TrueSec. With a focus on OS deployment through SCCM/MDT, group policies, active directory, virtualisation and office 365, Maurice has been a Windows Server MCSE since 2008 and was awarded Enterprise Mobility MVP in March 2017.