Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello. I have a txt file of serv

Status
Not open for further replies.

ste52653

IS-IT--Management
Apr 10, 2007
36
CA
Hello.
I have a txt file of servers (servers.txt) to query and I have a txt file of the corporate patch requirements (32bitpatches.txt and 64bitpatches.txt) that contain the kb#'s for each patch. Normally I would run a script (checkpatch.vbs) to produce a list of installed patches and then manually check them against my list of required patches to see if anything is missing. I would like to automate this process a bit more but with my very limited vbs knowledge I'm having a hard time. Could anyone help me make this script produce an output of just the missing patches? Here's what I have so far...

CheckOS.vbs (I use this to see if the OS is 32 or 64 bit)
Code:
Const X64BIT = "x64"
strComputer = "."
arrOSVers = Array("5.2.3790") 'Windows Server 2003 or R2
Set objWMIService = GetObject("winmgmts:\\" & strComputer)
Set colOSes = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each objOS in colOSes 'Only one OS, even on dual-boot machines
  Wscript.Echo "  OS: " & objOS.Caption 'Name
  WScript.Echo "  Service Pack: " & objOS.ServicePackMajorVersion & "." & _
   objOS.ServicePackMinorVersion
  intCount = 0
  For Each strOSVer In arrOSVers
    If objOS.Version = strOSVer Then
      intCount = 1
    End If
  Next
  If (intCount = 0) Or (InStr(objOS.Caption, X64BIT) = 0) Then
    Wscript.Echo "  Operating System is 32-Bit"
	Else Wscript.Echo "  Operating System is 64-Bit"
  End If
Next

Patch.vbs (I use this to get the installed patches on the server)
Code:
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\scripts\servers-test.txt", ForReading)

strText = objTextFile.ReadAll
objTextFile.Close

arrComputers = Split(strText, vbCrLf)

For Each strComputer in arrComputers
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Wscript.Echo strComputer

Set colQuickFixes = objWMIService.ExecQuery _
("Select * from Win32_QuickFixEngineering")
For Each objQuickFix in colQuickFixes

If NOT objQuickFix.HotFixID = "File 1" then
	Wscript.Echo objQuickFix.HotFixID
	Else
	End If
Next

Wscript.Echo ""
Wscript.Echo ""
Next

I'd like to get these two scripts to work to gether and check the server for os bit type, then read the correct required patch file, then check to see if the patches are installed on the server and output the "missing patches" to a file.

Any help getting these scripts to work together would be appreciated.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top