MSEndpointMgr

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;

  1. Create Configuration Item

  2. Select Supported Platforms

    In this section we will pick which operating systems are applicable for SCCM distribution points

  3. Settings

    Here we will create a new setting entry that will contain both the discovery and remediation scripts required

    Discovery Script

    Remediation Script

  4. Compliance Rules

    Here we will specify when to run the remediation script you created in the previous step

Configuration Baseline

Now in order to apply the Configuration Item we will need to create a Configuration Baseline for the SCCM Server Device Collection.

  1. Create a new Configuration Baseline

  2. Set Evaluation Conditions

    Here we will add the Configuration Baseline we created earlier;

  3. Deploy the Configuration Baseline

    Set your schedule and generate an alert if required..

Monitoring

Now sit back, relax and watch your good work take hold across your estate;

Savings Examples

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!.

Script Download

The automated and manual scripts can be downloaded from the Microsoft Technet script gallery – https://gallery.technet.microsoft.com/IIS-Log-Maintenance-6f357306

References

A special thanks goes out to Johan Arwidmark for sharing this clean up script on his DeploymentResearch blog (https://deploymentresearch.com/Research/Post/563/A-little-bit-of-ConfigMgr-housekeeping).

(6412)

Maurice Daly

Maurice has been working in the IT industry for the past 20 years and currently working in the role of Senior Cloud Architect with CloudWay. 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. Most recently his focus has been on automation of deployment tasks, creating and sharing PowerShell scripts and other content to help others streamline their deployment processes.

6 comments

  • Hey, thanks for a great blog! Am I totally blind or are there no exported CI CAB files to download?

    • Hi Dan,

      There isn’t an exported CI as such, the script used within the CI is included with a link and the steps are all there to set up the CI/CB.

      Maurice

  • This looks interesting, but quite a few images are broken for me, so I cant see the detail on configuring this.

    I presume this could be used for maintaining IIS logs on any server (not just SCCM servers).

    • Hi Ben,

      That was an old post and it appears there was some issues with the post import from the DeployEverything blog. I have just updated it and you could apply the same logic to other non ConfigMgr related IIS instances.

      Maurice

Sponsors