This script allows to increase the SCCM cache size of a workstation.
In the following example:
- If free space on drive is equal or greater than 20 Go, the cache size is set to 10240 Mo
- If free space on drive is equal or greater than 40 Go, the cache size is set to 20480 Mo
#Initialize the CCM COM Objects
$CCM = New-Object -com UIResource.UIResourceMGR
#USe GetCacheInfo method to return Cache properties
$CCMCache = $CCM.GetCacheInfo()
#Get the current cache location
$CCMCacheDrive = $CCMCache.Location.Split("\")[0]
#Check Free space on drive
$Drive = Get-WMIObject -query "Select * from Win32_LogicalDisk where DeviceID = '$CCMCacheDrive'"
#Convert freespace to GB for easier check
$FreeSpace = $Drive.FreeSpace/1GB
#Check Sizes and set Cache
If ($Freespace -ge 20) {
#Free space moderate
$CacheSize = 10240
}
If ($Freespace -ge 40) {
#Plenty of space
$CacheSize = 20480
}
#Set Cache Size
$CCMCache.TotalSize = $CacheSize
Write-Host (Get-WMIObject -namespace root\ccm\softmgmtAgent -class CacheConfig).Size