This script will connect to a computer remotely and get the updates installed along with date and domain info. I haven’t formatted the script correctly for display on the web so you might have to do some editing. The script will put the info in a csv file. This script was written with help from others on the net along with MS documentation. I know it needs more commenting but I’m really lazy, Sorry.
const ForReading=1
const ForWriting=2
const ForAppending=8
Dim ObjFso
Set ObjFso = CreateObject(”scripting.filesystemobject”)
Set objTSIn = objFSO.OpenTextFile(”c:\Temp\Computers.txt”)
Set objTSOut = objFSO.CreateTextFile(”c:\temp\Report.csv”,2, True)
objTSOut.Write(”Computer Name” & Vbtab & “Date Installed” & vbTab & “Update Title” & vbTab & “Domain” & vbCr)
Do While Not objTSIn.AtEndOfStream
On Error Resume next
strComputer = objTSIn.ReadLine
Set objSession = CreateObject(”Microsoft.Update.Session”, strComputer)
If Err.Number <> 0 Then
Set objLogOut = objFSO.CreateTextFile(”c:\temp\log.txt”,2, True)
objLogOut.Write(”Connection failed on: ” & strComputer & ” on ” & Now & vbCrLf)
ElseIf Err.Number = 0 Then
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount
Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)
For Each objEntry in colHistory
objTSOut.Write(strComputer & vbTab & objEntry.Date & vbTab & objEntry.Title & vbtab)
Set objWMISvc = GetObject( “winmgmts:\\” & strComputer & “\root\cimv2″ )
Set colItems = objWMISvc.ExecQuery( “Select * from Win32_ComputerSystem”, , 48 )
For Each objItem in colItems
objTSOut.Write(objItem.Domain & vbCrLF)
Next
Next
End If
Loop
WScript.Echo “Script Done!”
objTSOut.Close
0 Responses to “Inventory Installed MS Updates”