Академический Документы
Профессиональный Документы
Культура Документы
Here is a VB script to create server patch status report in excel and the report can also be used as server inventory.
Please note that the script creates an instance of the Microsoft.Update.Session object, then uses the
CreateUpdateSearcher method to create an instance of the Searcher object. We could actually create the Searcher
object directly but by using the Session object we can get this script to run against remote computers!
intRow = 2
objExcel.Range("A1:M1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
If Err.Number = 0 Then
GetWMI
' (default) -- talk to the server rather than using locally cached information;
objsearcher.Online = True
Set oSearchResult = objsearcher.Search("DeploymentAction='Installation'" _
& " and IsAssigned=1 and IsInstalled=0 or DeploymentAction=" _
& "'Uninstallation' and IsAssigned=1 and IsPresent=1 or" _
& " DeploymentAction='Installation' and IsAssigned=1 and" _
& " RebootRequired=1 or DeploymentAction='Uninstallation' and" _
& " IsAssigned=1 and RebootRequired=1")
If oSearchResult.Updates.Count = 0 Then
objExcel.Cells(intRow, 12).Value = "Computer is Up-To-Date"
End If
For y = 0 to oSearchResult.Updates.Count - 1
Set oUpdate = oSearchResult.Updates(y)
If ((oUpdate.DeploymentAction = 1 And Not oUpdate.IsInstalled) Or _
(oUpdate.DeploymentAction = 2 And oUpdate.IsPresent)) Then
objExcel.Cells(intRow, 12).Value = "Some updates are still available to your computer."
End If
Next
For y = 0 to oSearchResult.Updates.Count - 1
Set oUpdate = oSearchResult.Updates(y)
If oUpdate.RebootRequired Then
objExcel.Cells(intRow, 12).Value ="Reboot Required"
End If
Next
Next
Else
GetWMI
Err.Clear
End If
intRow = intRow + 1
Err.Clear
Loop
Wscript.Echo "Done"
'*******************************************************************************************
**********************************
'Get Information from WMI
Sub GetWMI
Err.Clear
End Sub