Latest Posts

Setting cache size on clients with script

Do you want to change the SMS/SCCM client cache size setting in your environment you can do this with a script. I will show you 2 examples of doing it.

On Error Resume Next
 Set oUIResource = CreateObject("UIResource.UIResourceMgr")
Set objCacheInfo = oUIResource.GetCacheInfo
 nValueToSet = 20480
 objCacheInfo.TotalSize = nValueToSet

If you would like to deploy it via SMS/SCCM with different sizes you can use the script below. Save it as a ex. setclientcachesize.vbs script and create a folder in our package area and create different programs for it.

  • setclientcachesize.vbs 10240
  • setclientcachesize.vbs 15360
  • setclientcachesize.vbs 20480

If you would like to set your client cache size to a static value a script like this would to it. Save the code and save it as a .vbs script, and deploy in preferred way. To change the size change the value 20480 to preferred value in MB.

On Error Resume Next
 Set oUIResource = CreateObject("UIResource.UIResourceMgr")
Set objCacheInfo = oUIResource.GetCacheInfo
 nValueToSet = wscript.arguments(0)
 objCacheInfo.TotalSize = nValueToSet

 

Delete files older then x days

When I configure System Center Configuration Manager I always setup a cleanup job to delete certain files that will fill up the disks. An example is the IIS log files that potentially will grow allot. So first I move them off the default location on the C drive to another content drive, and then I configure a scheduled task to run a script that removes older files. I usually keep 7 days of logs for troubleshooting purposes.

Below you have a sample script to delete files older then 7 days. It can easily be changed for your own preferences.

'This is a script to delete files older then specified days
Option Explicit

Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile
Dim iDaysOld
'iDaysold = Delete files older then x amount of days
iDaysOld = 7

'sDirectoryPath = "Folder to deleteFiles in"
sDirectoryPath = "C:Tempforanexample"

On Error Resume Next

Set oFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(sDirectoryPath) Then
Set oFolder = oFSO.GetFolder(sDirectoryPath)
Set oFileCollection = oFolder.Files

For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - iDaysOld) Then
oFile.Delete(True)
End If
Next
else
WScript.Echo "No Folder"
End If

Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

 

 

MSFAQ.SE

MSFAQ

Hi, as many of you noticed my blog was down for a long period in the beginning of 2013, this was due to issues with my provider having issues with DDOS attacks wich keep my site offline and unresponsive , I have blogged on MSFAQ.SE since 2006 so its a bit sad but I also felt I wanted something new and fresh so I started this new blog instead where you can follow the trails I set in the world of System Management.

So stay tuned here on cmtrace.com instead.