GFI Script to Show Windows Update Settings

I wanted to be able to quickly check the Windows Update settings for a bunch of workstations using the GFI MAX RemoteManagement dashboard. I didn’t want to change the Windows Update settings (I’m using Group Policy for that), just check them.

I found a Fixit script that did something similar, and adapted it for my needs.

As with many scripts, there is a core command that retrieves the information that you need. In this case, it’s a COM object, retrieved in PowerShell as follows:

$objAutoUpdate = New-Object -ComObject "Microsoft.Update.AutoUpdate"
$objAutoUpdate.Settings

If you just run that in your local PowerShell window, you should see a nice list of Windows Update settings. The rest of the script just adds explanatory text, error trapping, comments, etc.

The Results

Once uploaded to the GFI dashboard as a custom script and deployed to a workstation, you will see the results in the Checks tab:

Windows Update script 1

If you click on the blue link, you can then review the full output of the script:

Windows Update script 2

The Script

And here is the script that generates the output. As always when downloading code from the Internet, use at your own risk and your mileage may vary!

<#
.Synopsis
    Print the Microsoft auto-update settings for the local computer.

  Copyright (c) 2014 by MCB Systems. All rights reserved.
  Free for personal or commerical use.  May not be sold.
  No warranties.  Use at your own risk.
.Notes 
    Name:       CheckAutoUpdateSettings.ps1
    Author:     Mark Berry, MCB Systems
    Created:    10/03/2014
    Last Edit:  10/10/2014

    Adapted from http://fixitscripts.com/problems/windows-update-settings.

    Changes:
    10/10/2014  - Reformat fixed output to be narrower.
#>

[Boolean]$ErrFound = $false

# The output below starts with two line breaks, so omit the newline here
Write-Host -NoNewLine ("Microsoft AutoUpdate settings on " + $env:COMPUTERNAME + ":")

try {
  $objAutoUpdate = New-Object -ComObject "Microsoft.Update.AutoUpdate"
  $objAutoUpdate.Settings
  
  # The rest of this is just static info on the meaning of various Settings.
  "NotificationLevel:"
  "1 - Never check for updates"
  "2 - Check for updates but let me choose whether to download and install them"
  "3 - Download updates but let me choose whether to install them"
  "4 - Install updates automatically"
  ""
  "ScheduledInstallationDay"
  "0 - Every day"
  "1-7 - Sunday through Saturday"
  "Note:  On Windows 8/2012 and later, ScheduledInstallationDay and"
  "       ScheduledInstallationTime are only reliable if the values" 
  "       are set through Group Policy."
  ""
  "Script execution succeeded"
  $ExitCode = 0
}
catch {
  ""
  $error[0]
  ""
  "Script execution failed"
	$ExitCode = 1001 # Cause script to report failure in GFI dashboard
}

""
"Local Machine Time:  " + (Get-Date -Format G)
"Exit Code: " + $ExitCode
Exit $ExitCode

3 thoughts on “GFI Script to Show Windows Update Settings

  1. Pingback: Updated PowerShell Script to Show Windows Update Settings | MCB Systems

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.