miércoles, 3 de febrero de 2010

MEJOR QUE LO HAGAN ELLOS




Hoy tuve la necesidad de pasar un reporte de los parches que recientemente se instalaron en mis servidores windows , alrededor de 40 parches de instalaron este mes , para no estar escribiendo cada uno de los parches me encontre con un Script en VBs que nos genera un archivo TXT que contiene algo asi por cada parche instalado:



Report run at 4/23/2006 2:42:14 PM
------------------------------------------------------------------
Title:   Security Update for Windows XP (KB908531)
Description:  A security issue has been identified in Windows Explorer that could allow an attacker to compromise your Windows-based system and gain control over it. You can help protect your computer by installing this update from Microsoft. After you install this item, you may have to restart your computer.
Date/Time in GMT: 4/18/2006 7:47:14 AM
Install mechanism: AutomaticUpdates
Install status:  Succeeded
------------------------------------------------------------------
El Script solo hay que copiarlo en un blog de notas, grabarlo con la extension “.VBS” y ejecutarlo. En mi caso lo nombre “Hotfix.VBS”

' Script that reports installed updates that are
' installed with Windows Update v5 technology
'
' Result will be written to %temp%\UpdateHistory.txt
' and then launched in Notepad
'
' Author: Torgeir Bakken
' Date 2004-08-12
'
Option Explicit
Const OverwriteIfExist = -1
Const OpenAsASCII   =  0
Dim oWU, iTHCount, colUpdate, oUpdate, sStatus, iTotal
Dim iSuccess, iFailed, iAborted, iUnknown, sErrorCode
Dim oFSO, oShell, sFile, f
On Error Resume Next
Set oWU = CreateObject("Microsoft.Update.Searcher")
If Err.Number <> 0 Then
   MsgBox "WU5 programming interface does not exist.", _
          vbInformation + vbSystemModal, "Update history"
   WScript.Quit
End If
On Error Goto 0
iTHCount = oWU.GetTotalHistoryCount
If iTHCount > 0 Then
   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oShell = CreateObject("Wscript.Shell")
   sFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UpdateHistory.txt"
   Set f = oFSO.CreateTextFile(sFile, _
                      OverwriteIfExist, OpenAsASCII)
   iTotal = 0
   iSuccess = 0
   iFailed = 0
   iAborted = 0
   iUnknown = 0
   f.WriteLine "Report run at " & Now
     f.WriteLine "---------------------------------" _
           & "---------------------------------"
   Set colUpdate = oWU.QueryHistory(0, iTHCount)
   For Each oUpdate In colUpdate
     f.WriteLine "Title:" & vbTab & vbTab & vbTab & oUpdate.Title
     f.WriteLine "Description:" & vbTab & vbTab & oUpdate.Description
     f.WriteLine "Date/Time in GMT:" & vbTab & oUpdate.Date
     f.WriteLine "Install mechanism:" & vbTab & oUpdate.ClientApplicationID
     sErrorCode = ""
     Select Case oUpdate.ResultCode
       Case 2
         sStatus = "Succeeded"
         iSuccess = iSuccess + 1
       Case 4
         sStatus = "Failed"
         iFailed = iFailed + 1
         sErrorCode = oUpdate.UnmappedResultCode
       Case 5
         sStatus = "Aborted"
         iAborted = iAborted + 1
       Case Else
         sStatus = "Unknown"
         iUnknown = iUnknown + 1
     End Select
     If sStatus = "Failed" Then
       f.WriteLine "Install error:" & vbTab & vbTab & sErrorCode
     End If
     f.WriteLine "Install status:" & vbTab & vbTab & sStatus
     f.WriteLine "---------------------------------" _
           & "---------------------------------"
     iTotal = iTotal + 1
   Next
   f.WriteLine
   f.WriteLine "Total number of updates found: " & iTotal
   f.WriteLine "Number of updates succeeded: " & iSuccess
   f.WriteLine "Number of updates failed: " & iFailed
   f.WriteLine "Number of updates aborted: " & iAborted
   f.Close
   oShell.Run "notepad.exe " & """" & sFile & """", 1, False
Else
   MsgBox "No entries found in Update History.", _
          vbInformation + vbSystemModal, "Update history"
End If

Benditos Script, MEJOR QUE LO HAGAN ELLOS
Si tiene dudas o comentarios no duden en dejarme un post
Referencia tomada de  http://msmvps.com/blogs/Athif/archive/2005/11/20/76035.aspx

No hay comentarios:

Publicar un comentario