Skip to content

Command ConvertTo DscV3ConfigurationDocument

Michael Zanatta edited this page Sep 16, 2026 · 1 revision

ConvertTo-DscV3ConfigurationDocument

Synopsis

Converts compiled pipeline resources into a DSC v3 configuration document that dsc.exe can consume.

Description

The runner's compiled Datum output is a runner-specific shape: a list of resources with type, name and properties, alongside pipeline-only keys such as condition, postExecutionScript, dependsOn, parameters, conditions and variables. That shape is consumed one resource at a time by Start-DscRunner; it is not a DSC v3 configuration document and cannot be handed to dsc config get|test|set as-is.

ConvertTo-DscV3ConfigurationDocument produces a schema-valid DSC v3 configuration document from those resources:

  • emits the document $schema so dsc.exe validates the payload,
  • keeps only the DSC v3 resource keys (name, type, properties) and drops every pipeline-only key, since DSC v3 has no notion of them,
  • validates that every resource has a non-empty name, a non-empty type, and that the type is structurally a DSC v3 identifier (namespace/name); when the caller supplies the set of types reported by dsc resource list, it additionally rejects any type that does not actually exist on the box,
  • aggregates every problem and throws a single, itemized error so an operator can fix all non-compliant resources in one pass rather than fix-and-rerun.

Resource ordering is intentionally the runner's responsibility (Sort-DependsOn), so dependsOn is not carried into the document — pass resources already in the order you want them evaluated. Likewise, properties are emitted verbatim: expand any runner variables (Expand-HashTable) before conversion if you want a fully-resolved document.

Parameters

Name Type Required Description
Resource Object[] Yes The compiled resources to convert. Each may be a [hashtable] (as produced by ConvertFrom-Yaml / ConvertFrom-Json -AsHashtable) or a [pscustomobject], and must expose type and name; properties defaults to an empty object when absent.
AvailableResourceType String[] No Optional set of resource types known to the target dsc.exe (e.g. the type values from dsc resource list). When supplied, a resource whose type is not in this set is reported as non-compliant — turning the structural check into a true existence check.
SchemaUri String No The $schema value to stamp on the document. Defaults to the DSC v3 configuration-document schema. Override only to target a specific pinned schema version.

Examples

Example 1

$doc = ConvertTo-DscV3ConfigurationDocument -Resource $pipeline.resources
$doc | ConvertTo-Json -Depth 32 | Set-Content ./config.dsc.json -Encoding utf8
dsc config get --file ./config.dsc.json

Example 2

$types = (dsc resource list --output-format json | ConvertFrom-Json).type
$doc = ConvertTo-DscV3ConfigurationDocument -Resource $compiled.resources -AvailableResourceType $types

Clone this wiki locally