Now Available:

line

Realtime Communities

line

Newsletter

Email Address:

line

RSS

  • XML
  • iTUNES
line

Ask the Expert

Have a question for our resident expert? .

« Hacking WSUS #3 of 5 -- Creating a MS Number to Knowledgebase Article Number Comparison Report | Main | Microsoft to donate to charity for every Windows Live Messenger IM session created »

Hacking WSUS #4 of 5 -- The "Big Red Button" or How to Patch When you want with WSUS

Most Windows administrators' biggest complaint about WSUS is its lack of an ability to patch on-demand, without having to wait for the Group Policy-scheduled time to arrive. Even in talking with the WSUS team, they have told me that they haven't planned for this capability natively in the WSUS 3.0 GUI.

However, within the scripting exposure, there is the capability to create a "YOU PATCH NOW!" script that will instruct a machine to scan itself, download any necessary patches, install them, and reboot if necessary. Since, according to Microsoft, this functionality is still not available when WSUS 3.0 arrives, keep this script close at hand. It will come in handy -- especially for patching servers!

As with some of our other scripts, you'll need to create a text file with a list of computer names -- one per line -- and reference that file when you run the script. An example: youPatchNOW.vbs computers.txt.

Click the link below for the code:

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

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

TrackBack

TrackBack URL for this entry:
https://realtime-windowsserver.com/type/mt-tb.cgi/91

Most Active Posts

line

Library Resources

line
line

Recent Posts

  • Memorial Day! Take it Easy Today...
  • Microsoft SoftGrid Sequencing Best Practices
  • Holy timing, batman! Microsoft Press Releases Windows Server 2008 Book
  • CBT Nuggets "Introduction to VBScript" Series to be Released Soon
  • Free CBT Nuggets Citrix and SMS Videos
  • WSUS 3.0 Auto-Update Excludes SBS Servers
  • Sarbanes-Oxley Revision under Review -- This may be a Good Thing
  • WSUS 3.0 update posted to WSUS today
  • Citrix Access Suite 4.5 Video Demos Available
  • Arguably the Least Specific or the Most Necessary Terminal Server Hotfix Ever
line

Greg Shields' Bio:

Greg Shields is a Principal Consultant with 3t Systems in Denver, Colorado. With more than 10 years of experience in information technology, Greg has developed extensive experience in systems administration, engineering, and architecture specializing in Microsoft, Citrix, and VMware technologies. Greg is a Contributing Editor for both Redmond Magazine and Microsoft Certified Professional Magazine, authoring two regular columns along with numerous feature articles, webcasts, and white papers. He is known for his abilities to relate highly technical concepts with a drive towards fulfilling business needs. Greg is also a highly sought-after instructor and speaker, teaching system and network troubleshooting curriculum for TechMentor Events, a twice-annual IT conference, and producing computer-based training curriculum for CBT Nuggets on numerous topics. Greg is a triple Microsoft Certified Systems Engineer (MCSE) with security specialization and a Certified Citrix Enterprise Administrator (CCEA).