Documentation

win_reg_stat - returns information about a Windows registry key or property of a key

New in version 2.3.

Synopsis

  • Like win_file, win_reg_stat will return whether the key/property exists.
  • It also returns the sub keys and properties of the key specified.
  • If specifying a property name through property, it will return the information specific for that property.

Options

parameter required default choices comments
key
yes
The full registry key path including the hive to search for.
property
no
The registry property name to get information for, the return json will not include the sub_keys and properties entries for the key specified.

Examples

# Obtain information about a registry key using short form
- win_reg_stat:
    key: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
  register: current_version

# Obtain information about a registry key property
- win_reg_stat:
    key: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
    property: CommonFilesDir
  register: common_files_dir

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
win_reg_stat Information about the registry key or property specified. success dictionary
contains:
name description returned type sample
raw_value Returns the raw value of the registry property, REG_EXPAND_SZ has no string expansion, REG_BINARY or REG_NONE is in hex 0x format. REG_NONE, this value is a hex string in the 0x format. success, path/property exists and property specified string %ProgramDir%\\Common Files
sub_keys A list of all the sub keys of the key specified. success, path exists and property not specified list ['AppHost', 'Casting', 'DateTime']
exists States whether the registry key/property exists. success and path/property exists boolean True
type The property type. success, path/property exists and property specified string REG_EXPAND_SZ
properties A list of all the properties and their values in the key. success, path exists and property not specified list [{'binary_property': {'raw_value': ['0x01', '0x16'], 'type': 'REG_BINARY', 'value': [1, 22]}}, {'multi_string_property': {'raw_value': ['a', 'b'], 'type': 'REG_MULTI_SZ', 'value': ['a', 'b']}}]
value The value of the property. success, path/property exists and property specified string C:\\Program Files\\Common Files
changed Whether anything was changed. always boolean True


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Support

This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.