| 
| 
| 
| #203807 - 2011-11-19 02:35 AM  Re: Microsoft Update Session on remote system
[Re:  Lonkero] |  
| Allen   KiX Supporter
 
       
 Registered:  2003-04-19
 Posts: 4562
 Loc:  USA
 | 
I just tried the original script with the modified add code line on a remote pc and while it did produce errors on the screen, it also produced results.  You might remove some of you error checking and see what it gets you.
 
 
The operation completed successfully.
Invalid number of parameters.
Invalid number of parameters.
-2147352562
[317]
-2147352562
There was an error getting the update collection Invalid number of parameters.
Title:                   Update for Windows Server 2003 (KB2641690)
Description:             Install this update to resolve an issue which requires
an update to the certificate revocation list on Windows systems and to keep your
 systems certificate list up to date. After you install this update, you may hav
e to restart your system.
Update application date: 11/17/2011 3:39:47 PM
Operation type:         Installation
Operation result:       The operation completed successfully.
Update ID:              9b1eb814-0ee1-49c1-98cc-6f893ba8ba0f
------------------------------------------------------------?
Title:                   Windows Malicious Software Removal Tool - November 2011
 (KB890830)
Description:             After the download, this tool runs one time to check yo
ur computer for infection by specific, prevalent malicious software (including B
laster, Sasser, and Mydoom) and helps remove any infection that is found. If an
infection is found, the tool will display a status report the next time that you
 start your computer. A new version of the tool will be offered every month. If
you want to manually run the tool on your computer, you can download a copy from
 the Microsoft Download Center, or you can run an online version from microsoft.
com. This tool is not a replacement for an antivirus product. To help protect yo
ur computer, you should use an antivirus product.
Update application date: 11/12/2011 6:56:29 PM
Operation type:         Installation
Operation result:       The operation completed successfully.
Update ID:              846185a2-40da-4909-91d1-064ae329a0ff
 
 |  
| Top |  |  |  |  
| 
| 
| #203811 - 2011-11-21 03:45 PM  Re: Microsoft Update Session on remote system
[Re:  Allen] |  
| BradV   Seasoned Scripter
 
      
 Registered:  2006-08-16
 Posts: 687
 Loc:  Maryland, USA
 | 
Allen, you're correct.  I was single stepping through, saw the error and quit.  I came up with the following function:
 
 Function GetAllPatches(optional $strWks)
   ; Function:     GetAllPatches
   ;
   ; Author:       Brad Van Orden
   ;               Tremendous assist from Allen Powell
   ;
   ; Version:      1.1
   ;
   ; Version History: 21 November 2011, finished initial version
   ;                  21 November 2011, Added code to remove carriage returns
   ;                                    and line feeds from the description.
   ;
   ; Action:       Returns an array of all the updates on a given system.
   ;
   ; Syntax:       GetAllPatches([$strWks])
   ;
   ; Parameters:   Optional name of a remote system to query.
   ;               If omitted, will query the current system.
   ;
   ; Returns:      Array listing all updates and their status.
   ;
   ; Dependencies: None
   ;
   ; Kixtart version: tested with 4.61
   ;
   Dim $objSession, $objSearcher, $objUpdate, $colUpdates, $intI, $objSC, $intHistoryCount
   Dim $objIdentity, $objCodeO, $arrPatch[5,1], $intCount
   ;
   If $strWks = ""
      $strWks = "."
   EndIf
   ;
   $objSC                 = CreateObject("ScriptControl")
   $objSC.Language        = "VBScript"
   $objSC.AddCode('Set Session = CreateObject("Microsoft.Update.Session","' + $strWks + '")')
   $objSC.Run
   $objCodeO              = $objSC.CodeObject
   $objSession            = $objCodeO.Session
   $objSearcher           = $objSession.CreateUpdateSearcher
   $intHistoryCount       = $objSearcher.GetTotalHistoryCount
   $colUpdates            = $objSearcher.QueryHistory(0, $intHistoryCount)
   $intCount              = 0
   $arrPatch[0,$intCount] = "Title"
   $arrPatch[1,$intCount] = "Description"
   $arrPatch[2,$intCount] = "Update Application Date"
   $arrPatch[3,$intCount] = "Operation Type"
   $arrPatch[4,$intCount] = "Operation Result"
   $arrPatch[5,$intCount] = "Update ID"
   $intCount              = $intCount + 1
   For Each $objUpdate in $colUpdates
      $arrPatch[0,$intCount] = $objUpdate.Title
      $arrPatch[1,$intCount] = Join(Split(Join(Split($objUpdate.Description,Char(13))),Chr(10)))
      $arrPatch[2,$intCount] = $objUpdate.Date
      $intI                  = $objUpdate.Operation
      Select
         Case $intI = 1
            $arrPatch[3,$intCount] = "Installation"
         Case $intI = 2
            $arrPatch[3,$intCount] = "Uninstallation"
         Case 1
            $arrPatch[3,$intCount] = "Could not be determined"
      EndSelect
      $intI = $objUpdate.ResultCode
      Select
         Case $intI = 0
            $arrPatch[4,$intCount] = "The operation has not started."
         Case $intI = 1
            $arrPatch[4,$intCount] = "The operation is in progress."
         Case $intI = 2
            $arrPatch[4,$intCount] = "The operation completed successfully."
         Case $intI = 3
            $arrPatch[4,$intCount] = "The operation completed, but one or more errors occurred during the operation and the results are potentially incomplete."
         Case $intI = 4
            $arrPatch[4,$intCount] = "The operation failed to complete."
         Case $intI = 5
            $arrPatch[4,$intCount] = "The operation was aborted."
         Case 1
            $arrPatch[4,$intCount] = "Could not be determined."
      EndSelect
      $objIdentity           = $objUpdate.UpdateIdentity
      $arrPatch[5,$intCount] = $objIdentity.UpdateID
      $intCount              = $intCount + 1
      ReDim Preserve $arrPatch[5,$intCount]
   Next
   $intCount = $intCount - 1
   ReDim Preserve $arrPatch[5,$intCount]
   $GetAllPatches = $arrPatch
EndFunction
 Jooel, that was a typo.  I have to retype everything from the system where I am testing.  So, the above may also have a typo.  I hope not.
  
 I called it as:
 
 
 Break On
Dim $SO
;
$SO = SetOpt('Explicit',          'On')
$SO = SetOpt('NoMacrosInStrings', 'On')
;
Dim $strWks, $strComps, $colComps, $objComp, $arrPatches[5,0], $intI
;
$strComps = "u:\Desktop\computers.ini"
;
$colComps = Split(ReadProfileString($strComps,"computers",""),chr(10))
;
For Each $objComp in $colComps
   If $objComp <> ""
      $strWks - ReadProfileString($strComps,"computers",$objComp)
   EndIf
   $arrPatches = GetAllPatches($strWks)
Next
;
For $intI = 1 to Ubound($arrPatches,2)
   ? $arrPatches[0,0] + " : " + $arrPatches[0,$intI]
   ? $arrPatches[0,1] + " : " + $arrPatches[1,$intI]
   ? $arrPatches[0,2] + " : " + $arrPatches[2,$intI]
   ? $arrPatches[0,3] + " : " + $arrPatches[3,$intI]
   ? $arrPatches[0,4] + " : " + $arrPatches[4,$intI]
   ? $arrPatches[0,5] + " : " + $arrPatches[5,$intI]
   ? "----------------------------------------------------------------"
Next
 Thanks so much for the help!!!!
   
 Edited by BradV (2011-11-21 06:17 PM)
 Edit Reason: Modified to version 1.1
 |  
| Top |  |  |  |  
| 
| 
| #203812 - 2011-11-21 04:23 PM  Re: Microsoft Update Session on remote system
[Re:  BradV] |  
| BradV   Seasoned Scripter
 
      
 Registered:  2006-08-16
 Posts: 687
 Loc:  Maryland, USA
 | 
Guys, one minor flaw.  The description seems to have carriage returns and/or line feeds in it and this does not store well.  I tried doing:
 
 $arrPatch[1,$intCount] = Join(Split(Join(Split($objUpdate.Description,Char(13))),Chr(10)))
 but that doesn't seem to fix it.  Am I missing something here?
 |  
| Top |  |  |  |  
 Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
 
 | 
| 
 
| 0 registered
and 360 anonymous users online. 
 | 
 |  |