| description | Command line reference for the 'dsc config test' command |
|---|---|
| ms.date | 07/03/2025 |
| ms.topic | reference |
| title | dsc config test |
Verifies whether the resource instances in a configuration document are in the desired state.
dsc config test [Options] --file <FILE>dsc config test [Options] --input <INPUT>cat <FILE> | dsc config test [Options] --file -cat <PARAMETERS_FILE> | dsc config --parameters-file - test [Options] --file <FILE>cat <PARAMETERS_FILE> | dsc config --parameters-file - test [Options] --input <INPUT>The test subcommand verifies whether the resource instances in a configuration document are in
the desired state. When this command runs, DSC validates the configuration document before invoking
the test operation for each resource instance defined in the document.
The configuration document must be passed to this command as JSON or YAML with the --input or
--file option.
The command returns the status, desired state, actual state, and differing properties for the
resource instances defined in the configuration document saved as example.dsc.config.yaml. It
passes the configuration document to the command from stdin using the --file option.
# example.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Windows only
type: Microsoft.DSC/Assertion
properties:
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Current user registry example
type: Microsoft.Windows/Registry
properties:
keyPath: HKCU\example
_exist: true
dependsOn:
- "[resourceId('Microsoft.DSC/Assertion', 'Windows only')"cat ./example.dsc.config.yaml | dsc config test --file -The command uses the --file option to validate the configuration defined in the
example.dsc.config.yaml file.
dsc config test --file ./example.dsc.config.yamlThe command uses the --input option to validate the configuration stored in the $desired
variable.
dsc config test --input $desiredSpecifies the configuration document to validate state for.
The document must be a string containing a JSON or YAML object. DSC validates the document against the configuration document schema. If the validation fails, DSC raises an error.
This option is mutually exclusive with the --file option.
Type : string
Mandatory : false
LongSyntax : --input <INPUT>
ShortSyntax : -i <INPUT>Defines the path to a configuration document to validate state for.
The specified file must contain a configuration document as a JSON or YAML object. DSC validates the document against the configuration document schema. If the validation fails, or if the specified file doesn't exist, DSC raises an error.
You can also use this option to pass a configuration document from stdin, as shown in Example 1.
This option is mutually exclusive with the --input option.
Type : string
Mandatory : false
LongSyntax : --file <FILE>
ShortSyntax : -f <FILE>The --output-format option controls which format DSC uses for the data the command returns. The
available formats are:
jsonto emit the data as a JSON Line.pretty-jsonto emit the data as JSON with newlines, indentation, and spaces for readability.yamlto emit the data as YAML.
The default output format depends on whether DSC detects that the output is being redirected or captured as a variable:
- If the command isn't being redirected or captured, DSC displays the output as the
yamlformat in the console. - If the command output is redirected or captured, DSC emits the data as the
jsonformat to stdout.
When you use this option, DSC uses the specified format regardless of whether the command is being redirected or captured.
When the command isn't redirected or captured, the output in the console is formatted for improved readability. When the command isn't redirected or captured, the output include terminal sequences for formatting.
Type : string
Mandatory : false
ValidValues : [json, pretty-json, yaml]
LongSyntax : --output-format <OUTPUT_FORMAT>
ShortSyntax : -o <OUTPUT_FORMAT>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 : -hThis command returns formatted data that includes whether the operation or any resources raised any errors, the collection of messages emitted during the operation, and the test operation results for every instance. For more information, see dsc config test result schema.
For more information about the formatting of the output data, see the --output-format option.