Edit

Share via


registry config get

Synopsis

Retrieve registry configuration.

Important

The registry command and Microsoft.Windows/Registry resource are a proof-of-concept example for use with DSCv3. Don't use it in production.

Syntax

registry config get  [OPTIONS] --input <INPUT>

Description

The get command returns the current state of a registry key or value as an instance of the Microsoft.Windows/Registry resource. It expects input as a JSON instance of the resource for the --input option.

The input instance must define the keyPath property. It uses the keyPath value to determine which registry key to retrieve. If the input instance includes the valueName property, the command retrieves the current state of that value instead of the registry key.

Examples

Example 1 - Get a registry key

The command returns the current state of the specified registry key as a single line of compressed JSON without any whitespace.

$instance = @{
    keyPath = 'HKLM\Software\Microsoft\Windows NT\CurrentVersion'
} | ConvertTo-Json

registry config get --input $instance
{"keyPath":"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion"}

When the specified key doesn't exist, the _exist property is false.

$instance = @{
    keyPath = 'HKCU\Example\Nested\Key'
} | ConvertTo-Json

$instance | registry config get
{"keyPath":"HKCU\\Example\\Nested\\Key","_exist":false}

Example 2 - Get a registry value

The command returns the current state of the specified registry value as a single line of compressed JSON without any whitespace.

$instance = @{
    keyPath   = 'HKLM\Software\Microsoft\Windows NT\CurrentVersion'
    valueName = 'SystemRoot'
} | ConvertTo-Json

registry config get --input $instance | ConvertFrom-Json | Format-List
keyPath   : HKLM\Software\Microsoft\Windows NT\CurrentVersion
valueName : SystemRoot
valueData : @{String=C:\WINDOWS}

When the specified key doesn't exist, the output only includes the keyPath and _exist properties with _exist defined as false.

$instance = @{
    keyPath   = 'HKLM\Software\Microsoft\Windows NT\DoesNotExist'
    valueName = 'SystemRoot'
} | ConvertTo-Json

registry config get --input $instance | ConvertFrom-Json | Format-List
keyPath : HKLM\Software\Microsoft\Windows NT\DoesNotExist
_exist  : False

When the specified key exists but the value doesn't, the output only includes the keyPath, valueName, and _exist properties with _exist defined as false.

$instance = @{
    keyPath   = 'HKLM\Software\Microsoft\Windows NT\CurrentVersion'
    valueName = 'DoesNotExist'
} | ConvertTo-Json

registry config get --input $instance | ConvertFrom-Json | Format-List
keyPath   : HKLM\Software\Microsoft\Windows NT\CurrentVersion
valueName : DoesNotExist
_exist    : False

Options

-i, --input

Specifies the resource instance to retrieve from the system.

The instance must be a string containing a JSON object that is valid for the resource's instance schema.

Type        : string
Mandatory   : true
LongSyntax  : --input <INPUT>
ShortSyntax : -i <INPUT>

-h, --help

Displays the help for the current command or subcommand. When you specify this option, the application ignores all other options and arguments.

Type        : boolean
Mandatory   : false
LongSyntax  : --help
ShortSyntax : -h