Thursday, March 18, 2010

VBS Script To Verify If A Specified Hot Fix Is Installed On A List Of Remote Machines (Ref:http://myitforum.com/cs2/blogs/dhite/archive/2007/08/05/vbs-script-to-verify-if-a-specified-hot-fix-is-installed-on-a-list-of-remote-machines.aspx)

VBS Script To Verify If A Specified Hot Fix Is Installed On A List Of Remote Machines

This VBS script will take a Hot Fix ID from an input dialog box and will determine whether or not the Hot Fix is installed on a list of machines contained in a text file called MachineList.Txt. It will then write the results to an Excel spreadsheet.

Note: To hard code the Hot Fix ID you can remove the line that reads: strHotFixId = InputBox ("Enter Hot Fix ID") and replace it with: strHotFixId = "KB931836"

VBS Script:

strHotFixId = InputBox ("Enter Hot Fix ID")

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 = strHotFixId & " Install Date"

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\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering Where HotFixID ='" & strHotFixId & "'")

If colItems.Count > 0 Then

For Each objItem In colItems

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

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

Next

Else

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

objExcel.Cells(intRow, 2).Value = "Not Installed"

If objExcel.Cells(intRow, 2).Value = "Not Installed" Then

objExcel.Cells(intRow, 1).Font.ColorIndex = 3

objExcel.Cells(intRow, 2).Font.ColorIndex = 3

Else

End If

End If

intRow = intRow + 1

Loop

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

objExcel.Cells.HorizontalAlignment = 2

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

MsgBox "Done"

 

Reference: http://myitforum.com/cs2/blogs/dhite/archive/2007/08/05/vbs-script-to-verify-if-a-specified-hot-fix-is-installed-on-a-list-of-remote-machines.aspx

Print Friendly and PDF
Share/Bookmark

No comments:

Post a Comment