Thursday, 7 August 2008

Server Core - Updates are available + How to manually update

Despite the fact that the Windows Server 2008 Server Core edition has an exceedingly small footprint does not mean that it will not require updates.

They may come fewer and further between, but Server Core will still need to be updated:

Windows Server 2008 Standard (Core Installation) - 13 updates required.

Finding out how exactly we get the updates onto the Server Core installation is another story.

We look the Server Core Blog: Windows Update and More WMIC samples. Here we find the following command line to detect updates manually: Wuauclt /detectnow

However, we are not given any further indication as to how we must proceed to install those updates.

We search a little more, and our friend Sander Berkouwer on his blog The things that are better left unspoken gives us the process: (Manually) Updating Server Core .

The steps:
  1. Copy and paste the following script into NotePad on the Core installation:
    Set updateSession = CreateObject("Microsoft.Update.Session")
    Set updateSearcher = updateSession.CreateupdateSearcher()

    WScript.Echo "Searching for updates..." & vbCRLF

    Set searchResult = _
    updateSearcher.Search("IsInstalled=0 and Type='Software'")


    WScript.Echo "List of applicable items on the machine:"

    For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> " & update.Title
    Next

    If searchResult.Updates.Count = 0 Then
    WScript.Echo "There are no applicable updates."
    WScript.Quit
    End If

    WScript.Echo vbCRLF & "Creating collection of updates to download:"

    Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

    For I = 0 to searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> adding: " & update.Title
    updatesToDownload.Add(update)
    Next

    WScript.Echo vbCRLF & "Downloading updates..."

    Set downloader = updateSession.CreateUpdateDownloader()
    downloader.Updates = updatesToDownload
    downloader.Download()

    WScript.Echo vbCRLF & "List of downloaded updates:"

    For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    If update.IsDownloaded Then
    WScript.Echo I + 1 & "> " & update.Title
    End If
    Next

    Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")

    WScript.Echo vbCRLF & _
    "Creating collection of downloaded updates to install:"

    For I = 0 To searchResult.Updates.Count-1
    set update = searchResult.Updates.Item(I)
    If update.IsDownloaded = true Then
    WScript.Echo I + 1 & "> adding: " & update.Title
    updatesToInstall.Add(update)
    End If
    Next

    WScript.Echo vbCRLF & "Would you like to install updates now? (Y/N)"
    strInput = WScript.StdIn.Readline
    WScript.Echo

    If (strInput = "N" or strInput = "n") Then
    WScript.Quit
    ElseIf (strInput = "Y" or strInput = "y") Then
    WScript.Echo "Installing updates..."
    Set installer = updateSession.CreateUpdateInstaller()
    installer.Updates = updatesToInstall
    Set installationResult = installer.Install()

    'Output results of install
    WScript.Echo "Installation Result: " & _
    installationResult.ResultCode
    WScript.Echo "Reboot Required: " & _
    installationResult.RebootRequired & vbCRLF
    WScript.Echo "Listing of updates installed " & _
    "and individual installation results:"

    For I = 0 to updatesToInstall.Count - 1
    WScript.Echo I + 1 & "> " & _
    updatesToInstall.Item(i).Title & _
    ": " & installationResult.GetUpdateResult(i).ResultCode
    Next
    End If
  2. Save the file as WUA_SearchDownloadInstall.vbs in your preferred location.
  3. Navigate to the folder where the WUA_SearchDownloadInstall.vbs file is located.
  4. cscript WUA_SearchDownloadInstall.vbs [Enter]
  5. Answer Y to install the found updates.
  6. Once finished, note whether the Reboot Required: True flag is raised.
  7. If so: shutdown -r -t 15 [Enter]
    • If there are VMs running on the system, you can shut them down via the Hyper-V manager before rebooting, or let Hyper-V take care of it for you.
    • A snapshot of the VMs may be appropriate prior to updating and rebooting.
  8. Rerun the script once the server comes up again to verify that there are no further updates
If the above script does not copy and paste correctly, a download link for the .vbs file is available in Sander's blog linked above.

Our first Server Core setup to be updated is a 1U Xeon X3220 with 8GB of ECC RAM running a pair of Seagate ES series drives in a RAID 1 array. The updates took some time, around 30-45 minutes, to install during the reboot portion of the updates.

Once we had our Core box online and verified, we fired up our VMs with no issues.

Philip Elder
MPECS Inc.
Microsoft Small Business Specialists

*All Mac on SBS posts are posted on our in-house iMac via the Safari Web browser.

2 comments:

  1. We have tried running the script and manually detecting the updates required and neither have succeded. This has been with a proxy configured and a direct connection out. The script is erroring on Line 6 char 1. Is there anything we should be looking for? The installation is Core R2

    ReplyDelete
  2. Hi,

    The script started to hiccup with SP2 on Win2K8. I have not had the chance to dig into a replacement script though I think I know where to find one ... in Hyper-V Server 2008 R2.

    It is a matter of finding the time to dig into the H-V R2 box we have to get it.

    Philip

    ReplyDelete

NOTE: All comments are moderated.