Cleanup Site Concentrator

Table of Contents

Hey Guys,

I’ve had a number of site concentrators not clearing the cache properly.
According to http://www.allthingsmax.com/2011/12/saving-time-headaches-by-saving.html,

The Site Concentrator is self-cleaning, so in 30 days or less after download, the patches, etc. will be removed from the cache path automatically.

I have not found this to be the case, so have had to write a script to do it for me.
Paremeters to be passed are:
/ConcentratorPath: for where the cache Directory is located.
/ReportOnly: if you want to see how many files are over 30 days without deleting them.

Parameter Example:
/ConcentratorPath:”c:\UpdateCache” /ReportOnly:true

Option Explicit  
Dim FSO, Folder, File, DateRange, CurrentFolder, TotalSize, FileSize, Path, bDebug, ReportOnly
 
Set FSO = CreateObject("Scripting.FileSystemObject") 

Path = WScript.Arguments.Named("ConcentratorPath")
ReportOnly = WScript.Arguments.Named("ReportOnly")

If FSO.FolderExists(Path) = false Then
	WScript.echo "Concentrator Path not found."
	WScript.Quit(1)
End If

If lcase(ReportOnly) = "true" Then 
	bDebug = true
	if bDebug = true Then WScript.echo "*** No Files Deleted, ReportOnly Enabled ***"
End If 

DateRange = dateadd("d", -30, Now)
ProcessDirectory(Path) 

If TotalSize = 0 then
	WScript.echo "No Old Updates Found."
ElseIf TotalSize > 1024 then
	TotalSize = TotalSize / 1024
	WScript.echo "Total Size: " & FormatNumber(int(TotalSize * 100) / 100, 2) & "Gb"
Else
	WScript.echo "Total Size: " & FormatNumber(int(TotalSize * 100) / 100, 2) & "Mb"
End If

if bDebug = true Then WScript.echo "*** No Files Deleted, ReportOnly Enabled ***"
WScript.Quit(0)

Sub ProcessDirectory(Directory)
Set CurrentFolder = FSO.GetFolder(Directory) 

For Each File in CurrentFolder.Files
	If File.DateLastModified 

Our Services