Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Excel Operation

Excel Operation



|Views: 123|Likes:
Published by Amit Rathi

More info:

Published by: Amit Rathi on Dec 10, 2008
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Excel Operation in VB Script
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 theCreateUpdateSearcher 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!On Error Resume NextintRow = 2'Create an Excel Work Sheet;Set objExcel = CreateObject("Excel.Application")objExcel.Visible = TrueobjExcel.Workbooks.AddobjExcel.Cells(1, 1).Value = "Organization"objExcel.Cells(1, 2).Value = "Server Name"objExcel.Cells(1, 3).Value = "IP Address"objExcel.Cells(1, 4).Value = "Operating System"objExcel.Cells(1, 5).Value = "Service Packs"objExcel.Cells(1, 6).Value = "Manufacturer"objExcel.Cells(1, 7).Value = "Model"objExcel.Cells(1, 8).Value = "Serial Number"objExcel.Cells(1, 9).Value = "Last Patch Installed"objExcel.Cells(1, 10).Value = "Last Update Date"objExcel.Cells(1, 11).Value = "Last Reboot Time"objExcel.Cells(1, 12).Value = "Update Status"objExcel.Cells(1, 13).Value = "Report Time Stamp"objExcel.Range("A1:M1").SelectobjExcel.Selection.Interior.ColorIndex = 19objExcel.Selection.Font.ColorIndex = 11objExcel.Selection.Font.Bold = TrueobjExcel.Cells.EntireColumn.AutoFitSet Fso = CreateObject("Scripting.FileSystemObject")Set InputFile = fso.OpenTextFile("MachineList.Txt")Do While Not (InputFile.atEndOfStream)strComputer = InputFile.ReadLine'creating an instance of the Microsoft.Update.Session object;Set objSession = CreateObject("Microsoft.Update.Session", strComputer)
'Add Error Handling hereIf Err.Number = 0 Then'Call the CreateUpdateSearcher method;Set objSearcher = objSession.CreateUpdateSearcher 'Use the QueryHistory method to retrieve the desired updates;'The first 1 tells the script to begin its search with record 1 in the update history;'The second 1 tells the script to stop its search after record 1;'Updates are stored in reverse chronological order, with the most recent update as record 1;Set colHistory = objSearcher.QueryHistory(1, 1)For Each objEntry in colHistoryobjExcel.Cells(intRow, 2).Value = strComputer objExcel.Cells(intRow, 9).Value = objEntry.TitleobjExcel.Cells(intRow, 10).Value = objEntry.DateGetWMI'Get Update Status of the Servers;' (default) -- talk to the server rather than using locally cached information;objsearcher.Online = TrueSet 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 Err.Number <> 0 ThenobjExcel.Cells(intRow, 12).Value = "Detection Failed"End If If oSearchResult.Updates.Count = 0 ThenobjExcel.Cells(intRow, 12).Value = "Computer is Up-To-Date"End If For y = 0 to oSearchResult.Updates.Count - 1Set oUpdate = oSearchResult.Updates(y)If ((oUpdate.DeploymentAction = 1 And Not oUpdate.IsInstalled) Or (oUpdate.DeploymentAction = 2 And oUpdate.IsPresent)) Then

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->