VB Script to identify set of patch status in Multiple Remote Windows Server
-
Wednesday, December 14, 2011 7:33 AM
Thanks for the perfect Script... It helped a lot to minimize the work.
But a small query... Do we have any option to update the KB Article in separate txt file instead of adding into .vbs file (Same as sl.txt".
I have done the small modification in report section, After the path Status (True/False), I have added the KB Article Name also for better clarity of report.
_________________________________________________________________________________________________
On Error Resume Next
Const ForAppending = 9
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set reportfile = objFSO.CreateTextFile("PATCH_REPORT.txt")
'srvlist.close
reportfile.close
Set SrvList = objFSO.OpenTextFile("sl.txt", 1, TRUE)
Set reportfile = objFSO.CreateTextFile("PATCH_REPORT.txt", 2)
Patch1 = "KB111111"
Patch2 = "KB111111"
Patch3 = "KB111111"
Patch4 = "KB111111"
Patch5 = "KB111111"
Patch6 = "KB111111"
Patch7 = "KB111111"
Patch8 = "M2111111"
Patch9 = "M2111111"
Do until srvlist.atendofstream
srv = srvlist.readline
p1 = checkPatch(srv,Patch1)
p2 = checkPatch(srv,Patch2)
p3 = checkPatch(srv,Patch3)
p4 = checkPatch(srv,Patch4)
p5 = checkPatch(srv,Patch5)
p6 = checkPatch(srv,Patch6)
p7 = checkPatch(srv,Patch7)
p8 = checkPatch(srv,Patch8)
p9 = checkPatch(srv,Patch9)
'wscript.echo srv & vbtab & p1 & vbtab & p2 & vbtab & p3 & vbtab & p4 & vbtab & p5 & vbtab & p6 & vbtab & p7 & vbtab & p8 & vbtab & p9
reportfile.writeline srv & vbtab & p1 & vbtab & patch1 & vbtab & p2 & vbtab & patch2 & vbtab & p3 & vbtab & patch3 & vbtab & p4 & vbtab & patch4 & vbtab & p5 & vbtab & patch5 & vbtab & p6 & vbtab & patch6 & vbtab & p7 & vbtab & patch7 & vbtab & p8 & vbtab & patch8 & vbtab & p9 & vbtab & patch9
Loop
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@test.com"
objMessage.TextBody = "Patch Report"
objMessage.AddAttachment "PATCH_REPORT.txt"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserver.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
Function checkPatch(Server, KB)
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Server & "\root\cimv2")
Set cFixes = oWMI.ExecQuery("Select * from Win32_QuickFixEngineering where HotFixID = '" & KB & "'")
If cFixes.Count > 0 Then
checkPatch = True
Else
checkPatch = False
End If
End Function- Edited by Satheesh Thayal Wednesday, December 14, 2011 7:45 AM
All Replies
-
Wednesday, December 14, 2011 11:45 AM
What is the question? Are you just postng this as a solution?
You have posted it as a discussion.
jv -
Wednesday, December 14, 2011 2:31 PM
Thanks for the response.
I have the question, I need some modification on this vb script, current issue on the script, if I need to update any more KB Article... I need to modify report section and other two more places (I need to edit the .vbs file to update).
To avoid this work. I Need.
KB Article also to be in separte text file similr to server list.
So that I Can update multiple KB Articles in any moment.
Also I can ask my other team members to update only the KB Article in text file to avoid mistakes in .vbs file.
Can anybody helps on this?
Thanks
Satheesh Thayal
Satheesh -
Wednesday, December 14, 2011 5:36 PM
KB Article also to be in separte text file similr to server list.
So that I Can update multiple KB Articles in any moment.
Also I can ask my other team members to update only the KB Article in text file to avoid mistakes in .vbs file.
Start by looking for examples in teh Script Repository. You willfind many examples of how to use files for input and output.
We cannot understand what "So that I Can update multiple KB Articles in any moment" means. Does it mean you want to typein KB numbers? What do you mean by update?
Changing a text file can be accomplised using notepad. I don't see why you would want to do this by script.
Start by wditing your example script and post back with error messages and questoins. Take more time to clarify you request.
jv -
Wednesday, December 14, 2011 6:34 PM
Above script what i mentioned, if i need to update/modify any KB Article , Need an update in 3 places.
Instead of editing the vb script to update or Modify the KB Article. I want the KB Articles & Server list in separate text files to avoid mistakes in script file.
If not possible to modify the script, can you suggest any other script can fix my issue?
Because I need to run the script more than 100 server to identify the status of almost 80KB Articles, So I need server list and KB Article lists in separate file.
I am not too good in scripting
Thanks & Regards,
Satheesh
Satheesh -
Wednesday, December 14, 2011 6:47 PM
Instead of editing the vb script to update or Modify the KB Article. I want the KB Articles & Server list in separate text files to avoid mistakes in script file.
You can find examples of how to read from files in the Script Repository,
If not possible to modify the script, can you suggest any other script can fix my issue?
This can be done by modifying the script or creating a nwe script. Write your script and post back with any errors or issues you are having.
Because I need to run the script more than 100 server to identify the status of almost 80KB Articles, So I need server list and KB Article lists in separate file.
Same answer as a baove.
It appears that you are asking for someone to write a cusotm script for you. THe forum is for help for admins and techs who have questions about scripting. It is not a free script forum except for what is in the repository. You are expected to do the work of writing and testing the script as you need it.
Look for scripts in the repository and pick the ones that show how to do the various steps you need. Look at the main page of the scripting site for tutorials on how to write scripts.
Here are a couple of links:
http://technet.microsoft.com/en-us/scriptcenter/bb410849.aspxhttp://msdn.microsoft.com/en-us/library/aa711216(v=vs.71).aspx
jv

