Some of our older servers are running out of disk space on C:, so I needed to change the SCCM cache directory to D:. By default, this is where I wanted it anyway on our servers, leaving C: only for OS-related files. My OSD Task Sequences all have SMSCACHEDIR set to a folder on D in the client configuration step, but I noticed it wasn’t actually working. You know I had to find a way to fix that using powershell :D It actually ended up being really REALLY easy to do…

It’s a simple WMI query that applies a variable for the cache directory & size (either one, both, doesn’t matter, you choose).

**DISCLAIMER: For location, you do not want a trailing backslash “\” in the path, it will bork your advertisements and the path will end up with double backslashes, like D:\path\to\cache\\advID. I learned this the hard way.

I ended up creating different scripts, one to integrate into my OSD Task Sequence that simply does the following:

This is designed to run directly on the SCCM Client machine. I also have it set the cache size to 2GB. In my OSD Task Sequence, I put a reboot after this step so the agent runs with the new settings.

I have another that is designed to target computers based on SCCM Computer Collection:

This is designed to be ran from any machine that has network access to both the SCCM server and the SCCM clients. You’d need to change a few things for it to work in your environment, however, I’m sure you can figure it out.

I also added logic to validate D: even exists (it doesn’t on some of ours, so it quits, leaving default values), and validate the folder exists (create it if not). This is the end result that is a task in my OSD Task Sequence, it shows current config, sets the new config, then shows us the new config. Notice there’s no restart of the agent? That’s because it’ll fool SCCM into thinking the server rebooted unexpectedly and we don’t want that.