Microsoft Security Patch Script Project
Project ID: 1327996200
Project Details
  • Status:
    Closed (Cancelled)
  • Posted:
    1/31/2012 at 2:50 EST
  • Cancelled:
    2/28/2012 at 0:10 EST
  • Project Creator:
  • Budget:
    $10-200
  • Description:
    One of my responsibilities is to determine if several computers have received all their monthly Microsoft Security Patch Bulletins.

    I already have the script below which reads Active Directory and reports back all computers and the security Patches installed and write to a file the computer names and the security patches installed to a file. (but I don't want all patches just patches from my external list)

    However I need someone to modify the script so it can do the following:

    1. Only list/show the results of all the security patches from a specific external list, such as from a simple text file. So the program would have to loop through the list of KB number and check on every computer it finds in active director. (the script already does this it just doesn't read a list of specific numbers. One great wish list option would also be when I only want to search for a specific month; however I would still need to be able to search on specific KB's contained within a file; I guess I could comment out one or the other option.

    An example of the external list would be:

    KB653254
    KB654875
    KB658698


    2. I need to be able to total the results for each computer for example; "Computer-A has 10 Security Patches installed."

    3. (this final item is only a wish list) Create a bar chart which would show the totals. This could be done using either program itself not fancy looking but still you could tell it's a bar chart or you could link to a Microsoft Office program to create the chart too.

    Please take a look; you'll be surprised at how much is already doen for you; below is my working source code:


    *******************************************************************
    Const strNA = "Not Available"

    Const HKEY_CURRENT_USER = &H80000001

    Const HKEY_LOCAL_MACHINE = &H80000002

    Const ForReading = 1

    Const ForWriting = 2

    Const ForAppending = 8

    '*------------------------------------------------------------------------------------------------

    '* Change the filter below for the specific region or leave as strFilter="*" or strFilter="1STFLRCMP-*"

    '*------------------------------------------------------------------------------------------------

    strFilter="1STFLRCMP-*"

    '*------------------------------------------------------------------------------

    '* Reads in list of computers from Active Directory

    '*------------------------------------------------------------------------------

    Set objBaseLDAP = GetObject("LDAP://RootDSE")

    'Sub LoadComputers

    On Error Resume Next

    intSysCount = 0

    strNameSpace = objBaseLDAP.get("DefaultNamingContext")

    Const ADS_SCOPE_SUBTREE = 2

    '* Connect to Active Directory

    Set objConnection = CreateObject("ADODB.Connection")

    Set objCommand = CreateObject("ADODB.Command")

    objConnection.Provider = "ADsDSOObject"

    objConnection.Open "Active Directory Provider"

    '* Connect to output file

    '*------------------------------------------------------------------------------

    '* Save to a text file to the current root folder, with the following file name

    '*------------------------------------------------------------------------------

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objLogFile = objFSO.OpenTextFile _

    (".\SecurityBulletins.txt", ForWriting, True)



    '*------------------------------------------------------------------------------

    '* Log the start time when the script started; by default this is commented out.

    '*------------------------------------------------------------------------------



    '* objLogFile.Writeline("Start Altiris Report started: " & Now)

    Set objCommand.ActiveConnection = objConnection

    objCommand.CommandText = _

    "Select Name, Location, operatingSystemVersion from " & _

    "'LDAP://" & strNameSpace & "' where objectClass='computer'" & _

    "and Name='" & strFilter & "'"

    objCommand.Properties("Page Size") = 1000

    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    Set objRecordSet = objCommand.Execute

    ReDim arrRemSystems(objRecordSet.RecordCount - 1)

    objRecordSet.SortAscending("Name")

    objRecordSet.MoveFirst

    '* Build the array of computer names

    While Not objRecordSet.EOF

    If Not objRecordSet.Fields("AccountDisabled") Then

    arrRemSystems(intSysCount) = objRecordSet.Fields("Name")

    intSysCount = intSysCount + 1

    End If

    objRecordSet.MoveNext

    Wend

    '* sort the array of computer names lexigraphially (A-Z)

    For i = (UBound(arrRemSystems) - 1) to 0 Step -1

    For j= 0 to i

    If UCase(arrRemSystems(j)) > UCase(arrRemSystems(j+1)) Then

    strHolder = arrRemSystems(j+1)

    arrRemSystems(j+1) = arrRemSystems(j)

    arrRemSystems(j) = strHolder

    End If

    Next

    Next

    '* Get the status of each computer in the array

    For Each strRemComp In arrRemSystems

    '* Ping each computer to see if it responds

    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._

    ExecQuery("select * from Win32_PingStatus where address = '" & _

    strRemComp & "'")

    For Each objStatus in objPing

    '*------------------------------------------------------------------------------

    '* Added a header with the word Computer and the computer name following

    '*------------------------------------------------------------------------------

    strStatus = "" & strRemComp

    objLogFile.Writeline(strStatus)

    If IsNull(objStatus.StatusCode) or objStatus.StatusCode <>0 Then

    strReboot = "Not responding to ping!"

    strBGcolor = "red"

    strRemUser = strNA

    strUptimeFrmt = strNA

    strStatus = strReboot

    objLogFile.Writeline(strStatus)

    Else

    Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" & strRemComp & "\root\cimv2")

    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    strQuery = "Select * from Win32_QuickFixEngineering"

    Set colHotFixes = objWMIService.ExecQuery(strQuery, "WQL", ForwardOnly+ReturnImmediately)

    For Each objHotFix In colHotFixes

    With objHotFix

    strHotFixID = .HotFixID

    strDescription = .Description

    End With

    strStatus = strHotFixID

    objLogFile.Writeline(strStatus)

    Next

    For Each objService in colServices

    strSvcStatus = objService.State

    '* strStatus = " - Service Status - " & strSvcStatus

    '* strStatus = "" & strSvcStatus

    objLogFile.Writeline(strStatus)

    Next

    End If

    Next

    objLogFile.Writeline("")

    Next

    on error goto 0

    '*------------------------------------------------------------------------------

    '* Write the time the script completed; by default commented out.

    '*------------------------------------------------------------------------------

    '* objLogFile.Writeline("Hotfix report complete." & Now)

    objLogFile.Close

    'End Sub '* LoadComputers


    *******************************************************************
  • Tags:
Project Bids



(No bids have been placed yet. Click here to place the first bid on this Project.)