Email Notifications for Required Restarts in Windows Server 2008

windows-server-2008windows-update

Is it possible to have Windows send me an email when a restart is required to complete updates? I have my server setup to install updates automatically, but not restart afterwards. I have found that I can add actions for events in the event viewer, but I don't know what to look for.

Best Answer

Here is a portion of a PowerShell script I have set to run daily on a few of my servers.

##############################################
##    Review windows updates   ##
##############################################

$update = new-object -com Microsoft.update.Session
$searcher = $update.CreateUpdateSearcher()
$result = $searcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")

if ($result.updates.count -gt 0 ) 
{
    $updatealert = 1
    $update_body += "<hr><h1 style="" font-family: 'arial'"">There are ("+$result.updates.count+") pending Windows updates:</h1><table BORDER=1 BORDERCOLOR=#C2C2C2>"

    foreach($update in $result.updates)
    {
       $update_body += "<tr  style="" font-family: 'arial' font-size: 7px border:2px groove #FFFFFF"" bgcolor=#FFFF00><td>" + $update.Title + "</td><td>" + $update.Description + "</td></tr>"
       $i++
    }

    $update_body += "</table>"
}

The full script sends an html email with other info, but right at the top it tells me every day if there are Windows updates available.