VBS Script To Write SMS Client Cache Configuration Information To Excel

 

This VBS script will take a list of SMS client machine names from a text file called MachineList.Txt and will write the following SMS cache configuration information to an excel spreadsheet:  The cache’s present location, current size and if it is currently in use.

 

For more information see my post entitled: The SMS Advanced Client Temporary Program Download Folder Cache here:

 

http://myitforum.com/cs2/blogs/dhite/archive/2007/03/24/the-sms-advanced-client-temporary-program-download-folder-cache.aspx

 

 

VBS Script:

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Location"

objExcel.Cells(1, 3).Value = "Size (MB)"

objExcel.Cells(1, 4).Value = "In Use"

 

On Error Resume Next

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/ccm/SoftMgmtAgent")

Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

objExcel.Cells(intRow, 2).Value = objItem.Location

objExcel.Cells(intRow, 3).Value = objItem.Size

objExcel.Cells(intRow, 4).Value = objItem.InUse

intRow = intRow + 1

Next

Set colItems = Nothing

Set objWMIService = Nothing

Loop

 

objExcel.Range("A1:D1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Published Saturday, March 24, 2007 10:41 AM by dhite
Filed under:

Comments

No Comments