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.
-
1is this server in production? You should install updates manually... – Campo Sep 23 '10 at 19:47
-
This server is in production. Can I send email notifications when new updates are available then? – JamesArmes Sep 23 '10 at 20:04
4 Answers
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.

- 1,673
- 12
- 17
Are you using WSUS?
If you are, when you approve updates and they get installed, if the updates don't need a reboot the machines will show zero updates needed.
If they do need a reboot there will always be outstanding updates shown as even if the updates have been installed, until you reboot it won't register back to WSUS that the updates have been installed.
Hopefully that makes sense.

- 2,364
- 8
- 28
- 32
There must be a method of doing this. It's just a matter of figuring out how to detect that updates are available.
Check out the Windows Update API below. There are some script examples of how to detect if updates are available. A similar method could be used with a PowerShell script.
http://msdn.microsoft.com/en-us/library/aa387102(v=VS.85).aspx
Cheers, Trevor Sullivan

- 2,063
- 3
- 14
- 19
Yes. You can attach a task (send an email) to an event so you can have your server send you an email when it reboots and gives you one of the "standard" Windows starting events in the event log.

- 1,147
- 11
- 20
-
The problem is that I don't want it to reboot; I just want it to email me when it needs to reboot to finish installing updates. – JamesArmes Sep 28 '10 at 15:08
-
You get to choose which event log alert to use as the trigger. This doesn't actually reboot the server this will email you based on the event log entry you choose. – Mitch Sep 28 '10 at 17:35