locked
Client Side WSUS Update Schedule RRS feed

  • Question

  • I have an urgent need to get a critical update out to the field from my WSUS ASAP. (I know.."An emergency on my part does not necessarily constitute an emergency on your part"
    Is there a way to force the client to do an immediate pull from the WSUS?
    I found a script ((don't know how to run it or if it needs modification)See script below).
    I am running WSUS V3.0 SP1 on a Windows 2003 Server

    Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
    Set objSettings = objAutoUpdate.Settings
    
    objSettings.ScheduledInstallationDay = 3
    objSettings.ScheduledInstallationTime = 4
    
    objSettings.Save
    

    Any assistance would be greatfully appreciated

    SysAdmin
    Tuesday, March 31, 2009 2:44 PM

Answers

  • Here is a great script for this

    http://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx


    Brandon Shell [MVP]
    • Proposed as answer by BSonPosh Tuesday, March 31, 2009 2:47 PM
    • Marked as answer by William Tocci Wednesday, April 1, 2009 12:14 PM
    Tuesday, March 31, 2009 2:47 PM
  • Just for reference here is the powershell code I use to patch my systems.

    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    	$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    	$SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
    
    	$Index = 1
    	while ( $Index -le $SearchResult.Updates.Count)
    	{
    		$UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
    		$Update = $SearchResult.Updates.Item( $Index - 1 )
    		if ( $Update.EulaAccepted -eq 0 ) { $Update.AcceptEula() }
    		$UpdatesCollection.Add($Update) | out-null 
    		$UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
    		$UpdatesDownloader.Updates = $UpdatesCollection
    		Write-Host "Downloading $($UpdatesCollection | % { $_.Title})..." -foregroundcolor Cyan
    		$UpdatesDownloader.Download() | out-null
    		$UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
    		$UpdatesInstaller.Updates = $UpdatesCollection
    		Write-Host "Installing $($UpdatesCollection | % { $_.Title})..."  -foregroundcolor Cyan
    		$Result = $UpdatesInstaller.Install() | out-null
    		$Index++
    	} 
    • Marked as answer by William Tocci Wednesday, April 1, 2009 12:14 PM
    Tuesday, March 31, 2009 2:52 PM
  • I couldn't resist... I have a similar (very actually) script.

    Very nice :)

    # Get-WindowsUpdate.ps1
    function Get-WIAStatusValue($value)
    {
       switch -exact ($value)
       {
          0   {"NotStarted"}
          1   {"InProgress"}
          2   {"Succeeded"}
          3   {"SucceededWithErrors"}
          4   {"Failed"}
          5   {"Aborted"}
       } 
    }
    
    Write-Host
    
    Write-Host " - Creating WU COM object"
    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    
    Write-Host " - Searching for Updates"
    $SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
    
    Write-Host " - Found [$($SearchResult.Updates.count)] Updates to Download and install"
    Write-Host
    foreach($Update in $SearchResult.Updates)
    {
       # Add Update to Collection
       $UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
       $UpdatesCollection.Add($Update) | out-null
    
       # Download
       Write-Host " + Downloading Update $($Update.Title)"
       $UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
       $UpdatesDownloader.Updates = $UpdatesCollection
       $DownloadResult = $UpdatesDownloader.Download()
       $Message = "   - Download {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
       Write-Host $message   
    
       # Install
       Write-Host "   - Installing Update"
       $UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
       $UpdatesInstaller.Updates = $UpdatesCollection
       $InstallResult = $UpdatesInstaller.Install()
       $Message = "   - Install {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
       Write-Host $message
       Write-Host
    }

    Brandon Shell [MVP]
    • Marked as answer by William Tocci Wednesday, April 1, 2009 12:14 PM
    Tuesday, March 31, 2009 6:33 PM

All replies

  • Here is a great script for this

    http://msdn.microsoft.com/en-us/library/aa387102(VS.85).aspx


    Brandon Shell [MVP]
    • Proposed as answer by BSonPosh Tuesday, March 31, 2009 2:47 PM
    • Marked as answer by William Tocci Wednesday, April 1, 2009 12:14 PM
    Tuesday, March 31, 2009 2:47 PM
  • Just for reference here is the powershell code I use to patch my systems.

    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    	$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    	$SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
    
    	$Index = 1
    	while ( $Index -le $SearchResult.Updates.Count)
    	{
    		$UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
    		$Update = $SearchResult.Updates.Item( $Index - 1 )
    		if ( $Update.EulaAccepted -eq 0 ) { $Update.AcceptEula() }
    		$UpdatesCollection.Add($Update) | out-null 
    		$UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
    		$UpdatesDownloader.Updates = $UpdatesCollection
    		Write-Host "Downloading $($UpdatesCollection | % { $_.Title})..." -foregroundcolor Cyan
    		$UpdatesDownloader.Download() | out-null
    		$UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
    		$UpdatesInstaller.Updates = $UpdatesCollection
    		Write-Host "Installing $($UpdatesCollection | % { $_.Title})..."  -foregroundcolor Cyan
    		$Result = $UpdatesInstaller.Install() | out-null
    		$Index++
    	} 
    • Marked as answer by William Tocci Wednesday, April 1, 2009 12:14 PM
    Tuesday, March 31, 2009 2:52 PM
  • I couldn't resist... I have a similar (very actually) script.

    Very nice :)

    # Get-WindowsUpdate.ps1
    function Get-WIAStatusValue($value)
    {
       switch -exact ($value)
       {
          0   {"NotStarted"}
          1   {"InProgress"}
          2   {"Succeeded"}
          3   {"SucceededWithErrors"}
          4   {"Failed"}
          5   {"Aborted"}
       } 
    }
    
    Write-Host
    
    Write-Host " - Creating WU COM object"
    $UpdateSession = New-Object -ComObject Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    
    Write-Host " - Searching for Updates"
    $SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
    
    Write-Host " - Found [$($SearchResult.Updates.count)] Updates to Download and install"
    Write-Host
    foreach($Update in $SearchResult.Updates)
    {
       # Add Update to Collection
       $UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
       $UpdatesCollection.Add($Update) | out-null
    
       # Download
       Write-Host " + Downloading Update $($Update.Title)"
       $UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
       $UpdatesDownloader.Updates = $UpdatesCollection
       $DownloadResult = $UpdatesDownloader.Download()
       $Message = "   - Download {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
       Write-Host $message   
    
       # Install
       Write-Host "   - Installing Update"
       $UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
       $UpdatesInstaller.Updates = $UpdatesCollection
       $InstallResult = $UpdatesInstaller.Install()
       $Message = "   - Install {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
       Write-Host $message
       Write-Host
    }

    Brandon Shell [MVP]
    • Marked as answer by William Tocci Wednesday, April 1, 2009 12:14 PM
    Tuesday, March 31, 2009 6:33 PM