SlideShare a Scribd company logo
WSUS Sample Scripts These scripts were originally developed for WSUS 3.0, and have been lingering around my script quiver for years. They ’re yours to use, but are offered with no warranties, express or implied Use at your own risk! Because, well, I have to say that…  
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like. For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site,  www.ConcentratedTech.com .  For links to newly-posted decks, follow us on Twitter: @concentrateddon or @concentratdgreg This work is copyright ©Concentrated Technology, LLC
So, why scripting? There ’s a lot you can do with WSUS and the GUI console, but sometimes you have very specific needs. The WSUS GUI is slow Exporting compliance data isn ’t often user-friendly Some items not available or easy in the GUI No On-Demand patching engine! Scripting is just so darn fun…
What Can I Script? Although the WSUS server itself is mostly managed .NET code… … there are 11 COM objects on the client that can be interfaced with VBScript More, if you know COM and VB All are documented in the WSUS SDK. However, for those inexperienced in COM (like me), the WSUS SDK is cryptic at best. (Thank you Don Jones for your help with translation!) There is no central repository of script recipes to steal!
What Can I Script? All scriptable interfaces can be found on MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wua_sdk/wua/interfaces.asp The ones we can script in VBScript are: Microsoft.Update.AgentInfo Microsoft.Update.AutoUpdate Microsoft.Update.Downloader Microsoft.Update.Installer Microsoft.Update.Searcher Microsoft.Update.ServiceManager Microsoft.Update.Session Microsoft.Update.StringColl Microsoft.Update.SystemInfo Microsoft.Update.UpdateColl Microsoft.Update.WebProxy
Remote WUA Client Install This script takes as input a text file with computer names, one per line. This script has no output. When run, the WUA client is installed with the  /force  switch to force the installation Additionally, BITS 2.0 and WinHTTP 5.1 are installed. These are prerequisites for the next scripts to work properly.
Wsus sample scripts
Enumerate Installed Patches This script takes as input a text file with computer names, one per line. This script outputs a .CSV file showing each computer and the installed patches on that computer. Useful for auditing and compliance verification. Easy to generate.
Wsus sample scripts
Enumerate Patches Not Installed This script takes as input a text file with computer names – one per line. This script outputs a .CSV file showing each computer and the patches not installed on that computer. If the computer is connected to a WSUS server, it will show those patches where the Action is set to Install. If the computer is not connected to a WSUS server, it will verify its patch status against WU. … where all patches have  Action =  “Install” Also easier than GUI tool. Slow.
Wsus sample scripts
Multi-Machine On-Demand Patching (You Patch Now!) This script takes as input a text file with computer names, one per line. This script outputs a .CSV file showing each patch installed on that computer. The  Microsoft.Update.UpdateColl  object cannot be remotely created on the client. Thus, the download and install methods won ’t work. So, to fix this, the  WSUS-install.vbs  script actually launches the  WSUS-install-agent.vbs  script on each remote computer. Using PSExec!  Man, I love PSExec! You can either run  WSUS-install-agent.vbs  directly on a machine or use  WSUS-install.vbs  to push it to a list of machines.
Wsus sample scripts
Wsus sample scripts
Match q-Numbers to MS0x-0xx Numbers This script takes no input (but you ’ll need to point it to your WSUS server) This script outputs a .CSV file showing each Security update and the mapping between the knowledgebase article number (the q number) and the Microsoft advisory number (the MS number)
Wsus sample scripts
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like. For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site,  www.ConcentratedTech.com .  For links to newly-posted decks, follow us on Twitter: @concentrateddon or @concentratdgreg This work is copyright ©Concentrated Technology, LLC

More Related Content

PPTX
PPTX
Wsus best practices
PPTX
Virtualization auditing & security deck v1.0
PPT
Top ESXi command line v2.0
PPT
Virtualization today
PPT
Rapidly deploying software
PPT
Prepping software for w7 deployment
PPT
PowerShell Remoting
Wsus best practices
Virtualization auditing & security deck v1.0
Top ESXi command line v2.0
Virtualization today
Rapidly deploying software
Prepping software for w7 deployment
PowerShell Remoting

What's hot (20)

PPT
PPT
Securely connecting to apps over the internet using rds
PPT
WSUS Deployment on Windows Server 2008
PPTX
PowerShell crashcourse for sharepoint
PPT
Common WSUS Errors Codes - Decoded and Resolved
PPTX
Optimizing windows 8 for virtual desktops - teched 2013 Jeff Stokes
PDF
Wsus config[ver1.0]
PPTX
Windows 7 Deployment Enhancements
PPTX
Windows 7 client performance talk - Jeff Stokes
PPTX
Windows Deployment Tools And Methodologies
PPTX
Ws08 R2 Itpro Session 4 Virtualization Technologies
PDF
Vmware tools-installation-configuration
PPTX
Ewug.dk windows 10 deployment
PDF
100 most vmware q&a
PPTX
Vmware view overview
PPT
ZCM Software Packaging and ZENworks Application Virtualization
DOCX
Vmware inter
PPTX
Vmware thin app architecture
PDF
Admincenter
PPTX
Inside Windows 8 – Mastering Windows Deployment Services and MDT 2012 Update 1
Securely connecting to apps over the internet using rds
WSUS Deployment on Windows Server 2008
PowerShell crashcourse for sharepoint
Common WSUS Errors Codes - Decoded and Resolved
Optimizing windows 8 for virtual desktops - teched 2013 Jeff Stokes
Wsus config[ver1.0]
Windows 7 Deployment Enhancements
Windows 7 client performance talk - Jeff Stokes
Windows Deployment Tools And Methodologies
Ws08 R2 Itpro Session 4 Virtualization Technologies
Vmware tools-installation-configuration
Ewug.dk windows 10 deployment
100 most vmware q&a
Vmware view overview
ZCM Software Packaging and ZENworks Application Virtualization
Vmware inter
Vmware thin app architecture
Admincenter
Inside Windows 8 – Mastering Windows Deployment Services and MDT 2012 Update 1
Ad

Viewers also liked (20)

PPT
How-To: WSUS Reporting Made Easier
PPTX
PowerShell custom properties
PPT
PowerShell crashcourse
PPT
PowerShell 8tips
ODT
Examen 70-410
PDF
Redes locais
PPT
DOCX
Manual de Instalacion y Configuracion de WSUS
PDF
Certificate - Windows Server 2012 R2 Storage Jump Start New Choices
PPTX
Microsoft System Center Day 2011
PPTX
Roadshow: Windows Server 2016 «vNext»
PDF
Der flexible Arbeitsplatz von Microsoft - Windows 8
PPTX
Big Data DIY
PDF
Migration of a large IT-Infrastruktur
PDF
Modernes Rechenzentrum
PDF
Infrastructure Solution Day | Private
PPTX
Data Governance in Apache Falcon - Hadoop Summit Brussels 2015
PDF
Infrastructure Solution Day | Final
PDF
Microsoft Lizenzierung – Server
PPTX
Modernes Rechenzentrum - Future Decoded
How-To: WSUS Reporting Made Easier
PowerShell custom properties
PowerShell crashcourse
PowerShell 8tips
Examen 70-410
Redes locais
Manual de Instalacion y Configuracion de WSUS
Certificate - Windows Server 2012 R2 Storage Jump Start New Choices
Microsoft System Center Day 2011
Roadshow: Windows Server 2016 «vNext»
Der flexible Arbeitsplatz von Microsoft - Windows 8
Big Data DIY
Migration of a large IT-Infrastruktur
Modernes Rechenzentrum
Infrastructure Solution Day | Private
Data Governance in Apache Falcon - Hadoop Summit Brussels 2015
Infrastructure Solution Day | Final
Microsoft Lizenzierung – Server
Modernes Rechenzentrum - Future Decoded
Ad

Similar to Wsus sample scripts (20)

DOC
Wsus30 overview
DOC
Wsus30 overview
PPTX
Inventory your network and clients with PowerShell
PPTX
Windows Server 2008 Management
PPTX
Windows Server 2008 Management
PPTX
Introducing PowerShell 3.0
PPT
Windows_Server_2008_Management & Ack.ppt
PDF
WSUS30SP2StepbyStep
PDF
Wsus30sp2stepbystep
PPT
Common WSUS Issues in Deployment Operations and Diagnostics
PPTX
Windows 2012 R2 Multi Server Management
PDF
Designing an Update-Friendly MSI Installation
PPT
Installer benchmarking
DOC
Qtp wsh scripts examples
PPT
Network Implementation and Support Lesson 10 Server Administration - Eric V...
PDF
Sql Server & PowerShell
PPTX
Now Featuring the Latest Version!: Basic Patch Management for Basic Software
DOCX
Managing Web Infrastructure Systems with Windows PowerShell 2.0 Demo Script
PPTX
Managing enterprise with PowerShell remoting
PDF
SCCM 2007 Introduction - PICC 2012
Wsus30 overview
Wsus30 overview
Inventory your network and clients with PowerShell
Windows Server 2008 Management
Windows Server 2008 Management
Introducing PowerShell 3.0
Windows_Server_2008_Management & Ack.ppt
WSUS30SP2StepbyStep
Wsus30sp2stepbystep
Common WSUS Issues in Deployment Operations and Diagnostics
Windows 2012 R2 Multi Server Management
Designing an Update-Friendly MSI Installation
Installer benchmarking
Qtp wsh scripts examples
Network Implementation and Support Lesson 10 Server Administration - Eric V...
Sql Server & PowerShell
Now Featuring the Latest Version!: Basic Patch Management for Basic Software
Managing Web Infrastructure Systems with Windows PowerShell 2.0 Demo Script
Managing enterprise with PowerShell remoting
SCCM 2007 Introduction - PICC 2012

More from Concentrated Technology (14)

PPT
From VB Script to PowerShell
PPT
Supporting SQLserver
PPT
PS scripting and modularization
PPT
PS error handling and debugging
PPTX
PowerShell crashcourse for Sharepoint admins
PPTX
PowerShell crash course
PPTX
PowerShell and WMI
PPT
No-script PowerShell v2
PPT
Managing SQLserver
PPTX
Managing SQLserver for the reluctant DBA
PPTX
Implementing dr w. hyper v clustering
PPT
Iis implementation
PPT
Hyper v r2 deep dive
PPT
How to configure esx to pass an audit
From VB Script to PowerShell
Supporting SQLserver
PS scripting and modularization
PS error handling and debugging
PowerShell crashcourse for Sharepoint admins
PowerShell crash course
PowerShell and WMI
No-script PowerShell v2
Managing SQLserver
Managing SQLserver for the reluctant DBA
Implementing dr w. hyper v clustering
Iis implementation
Hyper v r2 deep dive
How to configure esx to pass an audit

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Advanced IT Governance
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Advanced Soft Computing BINUS July 2025.pdf
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation
Advanced IT Governance
The Rise and Fall of 3GPP – Time for a Sabbatical?
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton

Wsus sample scripts

  • 1. WSUS Sample Scripts These scripts were originally developed for WSUS 3.0, and have been lingering around my script quiver for years. They ’re yours to use, but are offered with no warranties, express or implied Use at your own risk! Because, well, I have to say that… 
  • 2. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like. For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com . For links to newly-posted decks, follow us on Twitter: @concentrateddon or @concentratdgreg This work is copyright ©Concentrated Technology, LLC
  • 3. So, why scripting? There ’s a lot you can do with WSUS and the GUI console, but sometimes you have very specific needs. The WSUS GUI is slow Exporting compliance data isn ’t often user-friendly Some items not available or easy in the GUI No On-Demand patching engine! Scripting is just so darn fun…
  • 4. What Can I Script? Although the WSUS server itself is mostly managed .NET code… … there are 11 COM objects on the client that can be interfaced with VBScript More, if you know COM and VB All are documented in the WSUS SDK. However, for those inexperienced in COM (like me), the WSUS SDK is cryptic at best. (Thank you Don Jones for your help with translation!) There is no central repository of script recipes to steal!
  • 5. What Can I Script? All scriptable interfaces can be found on MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wua_sdk/wua/interfaces.asp The ones we can script in VBScript are: Microsoft.Update.AgentInfo Microsoft.Update.AutoUpdate Microsoft.Update.Downloader Microsoft.Update.Installer Microsoft.Update.Searcher Microsoft.Update.ServiceManager Microsoft.Update.Session Microsoft.Update.StringColl Microsoft.Update.SystemInfo Microsoft.Update.UpdateColl Microsoft.Update.WebProxy
  • 6. Remote WUA Client Install This script takes as input a text file with computer names, one per line. This script has no output. When run, the WUA client is installed with the /force switch to force the installation Additionally, BITS 2.0 and WinHTTP 5.1 are installed. These are prerequisites for the next scripts to work properly.
  • 8. Enumerate Installed Patches This script takes as input a text file with computer names, one per line. This script outputs a .CSV file showing each computer and the installed patches on that computer. Useful for auditing and compliance verification. Easy to generate.
  • 10. Enumerate Patches Not Installed This script takes as input a text file with computer names – one per line. This script outputs a .CSV file showing each computer and the patches not installed on that computer. If the computer is connected to a WSUS server, it will show those patches where the Action is set to Install. If the computer is not connected to a WSUS server, it will verify its patch status against WU. … where all patches have Action = “Install” Also easier than GUI tool. Slow.
  • 12. Multi-Machine On-Demand Patching (You Patch Now!) This script takes as input a text file with computer names, one per line. This script outputs a .CSV file showing each patch installed on that computer. The Microsoft.Update.UpdateColl object cannot be remotely created on the client. Thus, the download and install methods won ’t work. So, to fix this, the WSUS-install.vbs script actually launches the WSUS-install-agent.vbs script on each remote computer. Using PSExec! Man, I love PSExec! You can either run WSUS-install-agent.vbs directly on a machine or use WSUS-install.vbs to push it to a list of machines.
  • 15. Match q-Numbers to MS0x-0xx Numbers This script takes no input (but you ’ll need to point it to your WSUS server) This script outputs a .CSV file showing each Security update and the mapping between the knowledgebase article number (the q number) and the Microsoft advisory number (the MS number)
  • 17. This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like. For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site, www.ConcentratedTech.com . For links to newly-posted decks, follow us on Twitter: @concentrateddon or @concentratdgreg This work is copyright ©Concentrated Technology, LLC

Editor's Notes

  • #4: Greg Shields
  • #5: Greg Shields
  • #6: Greg Shields Very useful web site: Navigate to http://www.microsoft.com/technet/community/columns/scripts/default.mspx and search for the July, 2005 issue of the Scripting Guys Newsletter “Tales from the Script”. This issue gives some good, but basic scripts you can use. We ’ll expand on those scripts shortly – and add to them the ability to use them on remote machines! There are a number of objects that can be created on the client, but only a few that can be interfaced through VBScript. Below is the mapping between the objects you can interface in VBScript and their associated COM object: Microsoft.Update.AgentInfo iWindowsUpdateAgentInfo Microsoft.Update.AutoUpdate iAutomaticUpdates Microsoft.Update.Downloader iUpdateDownloader Microsoft.Update.Installer iUpdateInstaller Microsoft.Update.Searcher iUpdateSearcher Microsoft.Update.ServiceManager iUpdateServiceManager Microsoft.Update.Session iUpdateSession Microsoft.Update.StringColl iStringCollection Microsoft.Update.SystemInfo iSystemInformation Microsoft.Update.UpdateColl iUpdateCollection Microsoft.Update.WebProxy iWebProxy Information about all of these can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wua_sdk/wua/interfaces.asp
  • #7: Greg Shields '========================================================================== ' ' VBScript Source File ' ' NAME: techmentor_wsus-install-client.vbs ' ' WARNING: This script is provided as-is with no implied or expressed ' warranties or guarantees of functionality. Use at your own risk. ' This script could lead to system problems or a system crash and ' the author of this script is not responsible or liable for any problems ' or errors associated with its use. Use of this script constitutes ' agreement with this warning. ' ' NOTE: This script installs the WUA client and its necessary pre-requisites ' onto a list of computers and reboots the computer. The individual ' pre-requisites noted below must be in the same folder as where the script is run. ' ' INPUTS: A filename of a text file that includes the computers you want ' to scan. One computer per line. ' ' OUTPUTS: None ' ' SYNTAX: techmentor_wsus-install-client.vbs computers.txt ' '==========================================================================
  • #8: Greg Shields strComputerList = WScript.Arguments.Item(0) strPreReq = "Windows2000-KB842773-x86-ENU.EXE" strPreReq2 = "WindowsInstaller-KB893803-v2-x86.exe" strAgent = "WindowsUpdateAgent20-x86.exe" Set objShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(strComputerList, 1, True) Do While f.AtEndOfLine <> True strComputer = f.ReadLine objShell.Run("psexec.exe \\\\" & strComputer & " -c " & strPreReq & " /quiet /norestart"), 0, True objShell.Run("psexec.exe \\\\" & strComputer & " -c " & strPreReq2 & " /quiet /norestart"), 0, True objShell.Run("psexec.exe \\\\" & strComputer & " -c " & strAgent & " /wuforce /quiet"), 0, True Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\\\" & strComputer & "\\root\\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Reboot() Next Loop WScript.Echo "Done!"
  • #9: Greg Shields '========================================================================== ' ' VBScript Source File ' ' NAME: techmentor_wsus-detectinstalled.vbs ' ' WARNING: This script is provided as-is with no implied or expressed ' warranties or guarantees of functionality. Use at your own risk. ' This script could lead to system problems or a system crash and ' the author of this script is not responsible or liable for any problems ' or errors associated with its use. Use of this script constitutes ' agreement with this warning. ' ' NOTE: This script leverages the WUA client to identify the updates ' currently installed on a list of computers. ' ' INPUTS: A filename of a text file that includes the computers you want ' to scan. One computer per line. ' ' OUTPUTS: A .CSV file that includes each computer and the currently installed ' updates on that computer. ' ' SYNTAX: techmentor_wsus_detectinstalled.vbs computers.txt ' '==========================================================================
  • #10: Greg Shields strComputerList = WScript.Arguments.Item(0) Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(strComputerList, 1, True) Set objTextFile = fso.OpenTextFile("OUTPUT.csv", 2, True) objTextFile.WriteLine("Computer Name,Update Title") Do While f.AtEndOfLine <> True strComputer = f.ReadLine Set objSession = CreateObject("Microsoft.Update.Session", strComputer) Set objSearcher = objSession.CreateUpdateSearcher() intHistoryCount = objSearcher.GetTotalHistoryCount Set colHistory = objSearcher.QueryHistory(0, intHistoryCount) For Each objHistory in colHistory objTextFile.WriteLine(strComputer & "," & Replace(objHistory.Title, ",", "")) Next Loop WScript.Echo "Done!"
  • #11: Greg Shields '========================================================================== ' ' VBScript Source File ' ' NAME: techmentor_wsus-detectNotInstalled.vbs ' ' WARNING: This script is provided as-is with no implied or expressed ' warranties or guarantees of functionality. Use at your own risk. ' This script could lead to system problems or a system crash and ' the author of this script is not responsible or liable for any problems ' or errors associated with its use. Use of this script constitutes ' agreement with this warning. ' ' NOTE: This script leverages the WUA client to identify the updates ' not installed on a list of computers. ' ' INPUTS: A filename of a text file that includes the computers you want ' to scan. One computer per line. ' ' OUTPUTS: A .CSV file that includes each computer and the currently ' uninstalled updates on that computer. ' ' SYNTAX: techmentor_wsus_detectNotInstalled.vbs computers.txt ' '==========================================================================
  • #12: Greg Shields strComputerList = WScript.Arguments.Item(0) Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(strComputerList, 1, True) Set objTextFile = fso.OpenTextFile("OUTPUT.csv", 2, True) objTextFile.WriteLine("Computer Name,Update Title") Do While f.AtEndOfLine <> True strComputer = f.ReadLine Set objSession = CreateObject("Microsoft.Update.Session", strComputer) Set objSearcher = objSession.CreateUpdateSearcher() Set objResults = objSearcher.Search("Type='Software'") Set colUpdates = objResults.Updates For i = 0 to colUpdates.Count - 1 If colUpdates.Item(i).IsInstalled = FALSE Then objTextFile.WriteLine(strComputer & "," & colUpdates.Item(i).Title) End If Next Loop WScript.Echo "Done!"
  • #13: Greg Shields '========================================================================== ' ' VBScript Source File ' ' NAME: techmentor_wsus-install.vbs ' ' WARNING: This script is provided as-is with no implied or expressed ' warranties or guarantees of functionality. Use at your own risk. ' This script could lead to system problems or a system crash and ' the author of this script is not responsible or liable for any problems ' or errors associated with its use. Use of this script constitutes ' agreement with this warning. ' ' NOTE: This script leverages PSExec to remotely launch the 'install agent' ' on a list of remote computers. ' ' INPUTS: A filename of a text file that includes the computers you want ' to scan. One computer per line. Also, the username and password ' of the administrator in "domain\\username" format ' ' OUTPUTS: None ' ' SYNTAX: wsus-install.vbs computers.txt domain\\username PassWord! ' '==========================================================================
  • #14: Greg Shields strComputerList = WScript.Arguments.Item(0) strUserName = WScript.Arguments.Item(1) strPassword = WScript.Arguments.Item(2) strAgent = "techmentor_wsus-install-agent.vbs" Set objShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(strComputerList, 1, True) Do While f.AtEndOfLine <> True strComputer = f.ReadLine fso.CopyFile strAgent, "\\\\" & strComputer & "\\admin$\\system32\\", True WScript.Echo ("psexec.exe \\\\" & strComputer & " -u " & strUserName & " -p " & strPassword & " " & strAgent) Set objExecObject = objShell.Exec("psexec.exe \\\\" & strComputer & " -u " & strUserName & " -p " & strPassword & " cscript " & strAgent) Loop WScript.Echo "Done! “ '========================================================================== ' ' VBScript Source File ' ' NAME: techmentor_wsus-Install-agent.vbs ' ' WARNING: This script is provided as-is with no implied or expressed ' warranties or guarantees of functionality. Use at your own risk. ' This script could lead to system problems or a system crash and ' the author of this script is not responsible or liable for any problems ' or errors associated with its use. Use of this script constitutes ' agreement with this warning. ' ' NOTE: This script is the agent that actually downloads and installs the ' individual updates on each computer. This script leverages WUA to ' determine the necessary updates, install them, and reboot. A ' wuauclt /detectnow may be needed for the machine to upload its status ' back to the WSUS server. This script can either be run directly on ' a machine console or can be remotely run via techmentor_wsus-install.vbs. ' ' INPUTS: A filename of a text file that includes the computers you want ' to scan. One computer per line. ' ' OUTPUTS: None ' '========================================================================== Set fso = CreateObject("Scripting.FileSystemObject") Set objAutomaticUpdates = CreateObject("Microsoft.Update.AutoUpdate") objAutomaticUpdates.EnableService objAutomaticUpdates.DetectNow Set objSession = CreateObject("Microsoft.Update.Session") Set objSearcher = objSession.CreateUpdateSearcher() Set objResults = objSearcher.Search("IsInstalled=0 and Type='Software'") Set colUpdates = objResults.Updates
  • #15: Greg Shields Set objUpdatesToDownload = CreateObject("Microsoft.Update.UpdateColl") intUpdateCount = 0 For i = 0 to colUpdates.Count - 1 intUpdateCount = intUpdateCount + 1 Set objUpdate = colUpdates.Item(i) objUpdatesToDownload.Add(objUpdate) Next If intUpdateCount = 0 Then WScript.Quit Else Set objDownloader = objSession.CreateUpdateDownloader() objDownloader.Updates = objUpdatesToDownload objDownloader.Download() Set objInstaller = objSession.CreateUpdateInstaller() objInstaller.Updates = objUpdatesToDownload Set installationResult = objInstaller.Install() Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo") If objSysInfo.RebootRequired Then Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\\\localhost\\root\\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Reboot() Next End If End If
  • #16: Greg Shields '========================================================================== ' ' VBScript Source File ' ' NAME: techmentor_WSUS-QtoMSMatch.vbs ' ' WARNING: This script is provided as-is with no implied or expressed ' warranties or guarantees of functionality. Use at your own risk. ' This script could lead to system problems or a system crash and ' the author of this script is not responsible or liable for any problems ' or errors associated with its use. Use of this script constitutes ' agreement with this warning. ' ' NOTE: For this script to function when not run on the WSUS server, you will ' need to enable TCP/IP and/or Named Pipes connections. Configuring the ' WSUS server for mixed mode authentication may also be likely. ' ' INPUTS: None ' ' OUTPUTS: A .CSV file with the update title matched with the MS number. ' '==========================================================================
  • #17: Greg Shields strWSUSServer = “<Enter WSUS Server here>" Set fso = CreateObject("Scripting.FileSystemObject") Set objTextFile = fso.OpenTextFile("OUTPUT.csv", 2, True) objTextFile.WriteLine("MS Number,Q Number") Set conn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") dbconn = "Driver={SQL Server};Server=" & strWSUSServer & ";Database=SUSDB" conn.open dbconn strSQLQuery = "SELECT dbo.tbSecurityBulletinForRevision.SecurityBulletinID, dbo.tbLocalizedProperty.Title FROM dbo.tbLocalizedPropertyForRevision INNER JOIN dbo.tbLocalizedProperty ON dbo.tbLocalizedPropertyForRevision.LocalizedPropertyID = dbo.tbLocalizedProperty.LocalizedPropertyID INNER JOIN dbo.tbSecurityBulletinForRevision ON dbo.tbLocalizedPropertyForRevision.RevisionID = dbo.tbSecurityBulletinForRevision.RevisionID WHERE (dbo.tbLocalizedPropertyForRevision.LanguageID = 1033) ORDER BY dbo.tbSecurityBulletinForRevision.SecurityBulletinID" rs.Open strSQLQuery, conn, 3, 3 While Not rs.EOF objTextFile.WriteLine(rs.Fields(0).Value & "," & Replace(rs.Fields(1).Value, ",", "")) rs.MoveNext Wend WScript.Echo "Done!"