Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to find out if a Windows Server (2003, 2008) has downloaded the Microsoft Windows updates and is just waiting for the user to confirm "Install Updates and Restart the server"?

We use WSUS and SSCM to collect and publish the updates, and the majority of the servers are on automatic install on a Sunday morning, mostly development and test server.

We have setup our important production servers to only install manually, but occastionally some servers are not rebooted manually for a while (humans forget!)

It would be nice if there was some method (powershell script, WMI query, some magic command) that I could use to count or discover if there where updates pending.

share|improve this question
up vote 4 down vote accepted

Here is the script I wrote. It will tell you:

  • How many patches are waiting to be installed
  • If the patches will require a reboot
  • If the server is currently waiting on a reboot to enable the patches

Example usage: C:\> cscript ServerPendingUpdates.vbs myserver01 myserver02

Connecting to myserver01 to check software update status...
myserver01 has 2 updates pending installation
myserver01 WILL need to be rebooted to complete the installation of these updates.
myserver01 is waiting for a REBOOT to complete a previous installation.



'# ServerPendingUpdates.vbs
'# Usage: cscript ServerPendingUpdates.vbs {servername} {servername} {servername} {servername}
'#    If no {servername} specified then 'localhost' assumed
'# To do: Error handling
Option Explicit
Dim strServer        : strServer         =  GetArgValue(0,"localhost")

'# Loop through the input parameters for each server
Dim i
For i = 0 To WScript.Arguments.Count - 1
    CheckServerUpdateStatus GetArgValue(i,"localhost") 'strServer


Function CheckServerUpdateStatus( ByVal strServer )

    WScript.Echo vbCRLF & "Connecting to " & strServer & " to check software update status..."

    Dim blnRebootRequired    : blnRebootRequired     = False
    Dim blnRebootPending    : blnRebootPending     = False
    Dim objSession        : Set objSession    = CreateObject("Microsoft.Update.Session", strServer)
    Dim objUpdateSearcher     : Set objUpdateSearcher    = objSession.CreateUpdateSearcher
    Dim objSearchResult    : Set objSearchResult     = objUpdateSearcher.Search(" IsAssigned=1 and IsHidden=0 and Type='Software'")

    Dim i, objUpdate
    Dim intPendingInstalls    : intPendingInstalls     = 0

    For i = 0 To objSearchResult.Updates.Count-1
        Set objUpdate = objSearchResult.Updates.Item(I) 

        If objUpdate.IsInstalled Then
            If objUpdate.RebootRequired Then
                blnRebootPending     = True
            End If
            intPendingInstalls    = intPendingInstalls + 1
            'If objUpdate.RebootRequired Then    '### This property is FALSE before installation and only set to TRUE after installation to indicate that this patch forced a reboot.
            If objUpdate.InstallationBehavior.RebootBehavior <> 0 Then
                '# InstallationBehavior.RebootBehavior = 0    Never reboot
                '# InstallationBehavior.RebootBehavior = 1    Must reboot
                '# InstallationBehavior.RebootBehavior = 2    Can request reboot
                blnRebootRequired     = True
            End If

        End If

    WScript.Echo strServer & " has " & intPendingInstalls & " updates pending installation"

    If blnRebootRequired Then
        WScript.Echo strServer & " WILL need to be rebooted to complete the installation of these updates."
        WScript.Echo strServer & " WILL NOT require a reboot to install these updates."
    End If

    If blnRebootPending Then
        WScript.Echo strServer & " is waiting for a REBOOT to complete a previous installation."
    End If 
End Function

Function GetArgValue( intArgItem, strDefault )
    If WScript.Arguments.Count > intArgItem Then
        GetArgValue = WScript.Arguments.Item(intArgItem)
        GetArgValue = strDefault
    End If
End Function
share|improve this answer
Nice script! Thanks for sharing. – AndyN Sep 24 '10 at 16:56
Hey @Guy , can you add alternate credentials to the connection? – ST8Z6FR57ABE6A8RE9UF May 17 '11 at 23:00
@ST8... I would run this using runas /user:youraccount cmd to create an authenticated shell and then run the script. – Guy May 18 '11 at 14:25
Great script, very useful for managing a large number of servers. – ckimbrell Jan 5 at 20:11

you can use wuinstall. It has a /search switch to see if there are updates pending. You can execute remotely with psexec.

Another option is to parse the %windir%\windowsupdate.log and look for stuff like this: # WARNING: Install call completed, reboot required = Yes, error = 0x00000000

share|improve this answer

I use the UpdateHf.vbs script authored by Rob Dunn & contributors. Because it runs locally on the host it is reporting on, I have it installed on all my machines. I created an MSI package and pushed it via GPO.

To trigger the reporting, I have a collection of powershell scripts that create scheduled tasks on an OU worth of servers, where each machine is scheduled to run UpdateHF.vbs locally and email me the results. I then use sorting rules to colorcode the resulting emails based on searching for distinctive text in the report.

UpdateHF.vbs is basically a wrapper around Microsoft's published Automatic Updates API, so with some digging I bet you could figure out which bit of script handles the "Reboot Pending" check, if all you wanted was a boolean reboot-status flag.

Here's the core of my system: Powershell fills in the variables on a call to schtasks.exe. (Note that if the password has complex characters, you need to escape them with a backtick.)

schtasks.exe /create /F /S $TargetHost /tn Patch /sc once /st $TargetTime /sd $StartDate /ru User /rp Password /tr "$WinPath\system32\cscript.exe $WinPath\UpdateHF.vbs $UpdateArgs"
share|improve this answer
Thanks - I looked at UpdateHf.vbs and worked out how to use CreateObject("Microsoft.Update.Session", strServer) in VBScript to create a small script to check a servers "not installed" status. – Guy Sep 23 '10 at 11:43

As an admin of the remote box, open an MMC and then add the Event Viewer Snapin. Select "Another Computer" (versus the default of "Local Computer" and input the target computer name. Then filter by event type to see only the ones you want! It's called "Windows Update Agent" and the description will begin with

"Installation Ready: The following updates are downloaded and ready for installation. This computer is currently scheduled to install these updates on [date]..."

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.