salt.modules.win_update

Module for running windows updates.

depends:
  • win32com
  • win32con
  • win32api
  • pywintypes

New in version 2014.7.0.

Set windows updates to run by category. Default behavior is to install all updates that do not require user interaction to complete. Optionally set categories to a category of your choice to only install certain updates. Default is to set to install all available but driver updates. The following example will install all Security and Critical Updates, and download but not install standard updates.

salt '*' win_update.install_updates categories="['Critical Updates', 'Security Updates']"

You can also specify a number of features about the update to have a fine grain approach to specific types of updates. These are the following features/states of updates available for configuring: .. code-block:: text

'UI' - User interaction required, skipped by default 'downloaded' - Already downloaded, included by default 'present' - Present on computer, included by default 'installed' - Already installed, skipped by default 'reboot' - Reboot required, included by default 'hidden' - Skip hidden updates, skipped by default 'software' - Software updates, included by default 'driver' - Driver updates, included by default

The following example installs all updates that don't require a reboot: .. code-block:: bash

salt '*' win_update.install_updates skips="[{'reboot':True}]"

Once installed Salt will return a similar output:

2 : Windows Server 2012 Update (KB123456)
4 : Internet Explorer Security Update (KB098765)
2 : Malware Definition Update (KB321456)
...

The number at the beginning of the line is an OperationResultCode from the Windows Update Agent, it's enumeration is described here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387095(v=vs.85).aspx. The result code is then followed by the update name and its KB identifier.

class salt.modules.win_update.PyWinUpdater(categories=None, skipUI=True, skipDownloaded=False, skipInstalled=True, skipReboot=False, skipPresent=False, skipSoftwareUpdates=False, skipDriverUpdates=False, skipHidden=True)
AutoSearch()

this function generates a search string. simplifying the search function while still providing as many features as possible.

Download()
GetAvailableCategories()
GetCategories()
GetDownloadResults()
GetInstallationResults()

this gets results of installation process.

GetInstallationResultsPretty()

converts the installation results into a pretty print.

GetSearchResults()
GetSearchResultsPretty()
Install()
Search(searchString)
SetCategories(categories)
SetSkip(skip, state)
SetSkips(skips)
salt.modules.win_update.download_updates(skips=None, retries=5, categories=None)

Downloads all available updates, skipping those that require user interaction.

Various aspects of the updates can be included or excluded. this feature is still in development.

retries
Number of retries to make before giving up. This is total, not per step.
categories

Specify the categories to update. Must be passed as a list.

salt '*' win_update.download_updates categories="['Updates']"

Categories include the following:

  • Updates
  • Windows 7
  • Critical Updates
  • Security Updates
  • Update Rollups

CLI Examples:

# Normal Usage
salt '*' win_update.download_updates

# Download critical updates only
salt '*' win_update.download_updates categories="['Critical Updates']"
salt.modules.win_update.install_updates(skips=None, retries=5, categories=None)

Downloads and installs all available updates, skipping those that require user interaction.

Add cached to only install those updates which have already been downloaded.

you can set the maximum number of retries to n in the search process by adding: retries=n

various aspects of the updates can be included or excluded. This function is still under development.

retries
Number of retries to make before giving up. This is total, not per step.
categories

Specify the categories to install. Must be passed as a list.

salt '*' win_update.install_updates categories="['Updates']"

Categories include the following:

  • Updates
  • Windows 7
  • Critical Updates
  • Security Updates
  • Update Rollups

CLI Examples:

# Normal Usage
salt '*' win_update.install_updates

# Install all critical updates
salt '*' win_update.install_updates categories="['Critical Updates']"
salt.modules.win_update.list_updates(verbose=False, skips=None, retries=5, categories=None)

Returns a summary of available updates, grouped into their non-mutually exclusive categories.

verbose
Print results in greater detail
retries
Number of retries to make before giving up. This is total, not per step.
categories

Specify the categories to list. Must be passed as a list.

salt '*' win_update.list_updates categories="['Updates']"

Categories include the following:

  • Updates
  • Windows 7
  • Critical Updates
  • Security Updates
  • Update Rollups

CLI Examples:

# Normal Usage
salt '*' win_update.list_updates

# List all critical updates list in verbose detail
salt '*' win_update.list_updates categories=['Critical Updates'] verbose=True