Sunday, August 3, 2014

Change Client Cache Size using DCM in SCCM 2012R2

Recently, I needed to set the cache size on our clients to push out some large applications.  There are many ways to accomplish this, but I thought it would be a good way to test out the Desired Configuration Management feature in SCCM 2012.  Configuration Management approaches computer management with a similar approach as the Application model in SCCM in that we have a method to ensure compliance.

Group Policy allows to push out a setting to your organization, but does not offer reporting about whether the change actually took place nor does it necessarily prevent someone on the workstation from changing that setting.  DCM allows you to define the setting and will check to ensure that it is correctly set using a remediation method you define on a schedule that you can define.  Along with Powershell Desired State Configuration, this is a paradigm shift in systems administration designed to prevent configuration "drift" and ensure standardization across your organization.

So, DCM is cool and probably something to look into.  I can't imagine it will take the place of group policy, but I think it could be an important tool to have knowledge of and access to.  Here's how I used it to ensure that our clients had a standardized cache size.

Start by navigating to the Assets and Compliance Node, expanding the "Compliance Settings" folder and selecting "Create Configuration Item".


On the next tab, give your configuration item a Name and a Description if you so choose  Select Windows as they type for this configuration item.  On the next tab, you can select which operating systems this applies to, but for our purposes, leave them all checked.
For this post, I'm leveraging the ccm namespace in WMI and retrieving the client cache from that via a Powershell script.  We'll also use Powershell to remediate non-compliant machines.

Create a new Setting, give it a name, and select "Script" as the Setting type and String as the Data type.
Click "Add Script..." under the Discovery Script section and paste the following code:

This will return the size of the client's cache.

Click "Add Script..." under the Remediation Script section and paste the following code:


This will run on non-compliant clients and set their cache size to whatever you need.  This is case, I changed it to 10GB by setting $cachesize = "10240".
Now, switch to the Compliance Rules tab and create a new compliance rule.
This will check for the value returned by our Discovery Script and consider all values other than 10240 as non-compliant and then subsequently run the Remediation Script to change the value to 10240.

We cannot deploy Configuration Items directly to a collection, they must be first assigned to a Configuration Baseline, so navigate to the Assets and Compliance node, expand the Compliance Settings folder and Configuration Baseline and select "Create Configuration Baseline", give it a name and then click "Add", select "Configuration Item" and select what we just created.
Click on your newly created Configuration Baseline and select Deploy.
Make sure that you check "Remediate noncompliant rules when supported" to ensure that the compliance settings will be enforced.  You can set the schedule on which compliance will be set and choose to generate alerts for non-compliance.  Set it to your test collection and we are done.