Controlling Automatic Updates Installation Time

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

To find out when Automatic Updates wakes your PC to install new updates, here is a script that will retrieve that information:

$updateObj = New-Object -ComObject Microsoft.Update.AutoUpdate
$day = $updateObj.Settings.ScheduledInstallationDay
$hour = $updateObj.Settings.ScheduledInstallationTime
$level = $updateObj.Settings.NotificationLevel

if ($level -eq 4) {
  if ($day -eq 0) {
    $weekday = 'every day'
  } else {
    $weekday = [System.DayOfWeek]($day-1)
  }
  
  "Automatic updates installed $weekday at $hour o'clock."
} else {
  'Updates will not be installed automatically. Check update settings for more info.'
}

To double-check settings or change them via UI, open the appropriate control like this:

$updateObj = New-Object -ComObject Microsoft.Update.AutoUpdate
$updateObj.ShowSettingsDialog()

Twitter This Tip! ReTweet this Tip!


Posted Nov 03 2011, 06:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.