Description

Check the SCCM Client cache size. It should either be the "my" default of 20GB our the vaule from the exceptions file in the format below.

 

I read the SCCM WMI Object the I import the SCCMCache.txt file. In my enviroment our stations names have "-" to seperate Site and then room so I break the computername into an array and then join the first to array items (A little messy I know)

I then try match exceptions against the computer site and room and update $SCCMCacheSize from the default size.

If the current size differs from $SCCMCacheSize I call Set-SCCMCacheSize function and use the .Put() to set the value.

 

Station,Size
WC-ROOM,51200
LE-E111,51200
SC-0174,51200

 

Script

PowerShell
Edit|Remove
#Windows PowerShellCopy Code########################################################################### 
# 
# NAME: Set-SCCMCache.ps1 
# 
# AUTHOR: John Grenfell 
# EMAIL: john.grenfell@wiltshire.ac.uk 
# 
# COMMENT: Set correct SCCS cache size, defaults to 20480 but also has a exceptions txt file.  
# 
# 
# Requires c:\bin lof logs and C:\System\SCCMCache.txt contains exceptions 
# 
#     Station,Size 
#     WC-ROOM,51200 
#     LE-E111,51200 
#     SC-0174,51200 
# 
# 
# 
# You have a royalty-free right to use, modify, reproduce, and 
# distribute this script file in any way you find useful, provided that 
# you agree that the creator, owner above has no warranty, obligations, 
# or liability for such use. 
# 
# VERSION HISTORY: 
# 1.3 29.06.2011 - Beta release 
# 
 
# 
########################################################################### 
 
 
 
$Path = "c:\bin\" 
$ProgessLog = "Set-SCCMCache.txt" 
 
Function Log-Message(){ 
    Param($Message = ".") 
    Write-Verbose $Message 
    Write-Output $Message | Out-File "$Path$ProgessLog" -Append -Force 
 
} 
 
 
$SCCMCurrentCache = Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig 
 
Function Set-SCCMCacheSize(){ 
    Param($SCCMCacheSize = ".") 
    $SCCMCurrentCache.Size = $SCCMCacheSize 
    $SCCMCurrentCache.InUse = "True" 
    $SCCMCurrentCache.Put() 
} 
 
Log-Message "Set-SCCMCache -Started - $(Get-Date)" 
 
#Get settings to work from 
 
Set-Item -Value $env:COMPUTERNAME -Path variable:\COMPUTERNAME 
$ComputerNameArray = $ComputerName.Split("-"$ComputerRoom = $ComputerNameArray[0] + "-" + $ComputerNameArray[1] 
 
$Settings = @(Import-CSV "C:\System\SCCMCache.txt") 
 
#Lets set the default cache size 
[int]$SCCMCacheSize = 20480 
 
ForEach ($Setting in $Settings){ 
    If($Setting.station -match $ComputerRoom){ 
        Log-Message "Set-SCCMCache -$($Setting.station) matched $ComputerRoom - $(Get-Date)" 
        $SCCMCacheSize = $Setting.Size 
        Log-Message "Set-SCCMCache -SCCMCacheSize is $SCCMCacheSize - $(Get-Date)" 
    } 
} 
 
If ($SCCMCurrentCache.size -ne $SCCMCacheSize){ 
    Log-Message "Set-SCCMCache -Setting Cache to $SCCMCacheSize - $(Get-Date)" 
    Set-SCCMCacheSize $SCCMCacheSize 
} 
 
Log-Message "Set-SCCMCache -Finished - $(Get-Date)"