Skip to content

Merge-Yaml

SYNOPSIS

Merges two or more complete YAML streams.

SYNTAX

__AllParameterSets

powershell Merge-Yaml [-InputObject] <string[]> [-SequenceAction <string>] [-ConflictAction <string>] [-NullAction <string>] [-Indent <int>] [-Depth <int>] [-MaxNodes <int>] [-MaxAliases <int>] [-MaxScalarLength <int>] [-MaxTagLength <int>] [-MaxTotalTagLength <int>] [-MaxNumericLength <int>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

Parses every input string as one complete YAML stream, merges documents pairwise by zero-based document index, and emits one deterministic YAML string directly from the resulting representation graphs. Every stream must contain the same positive number of documents. Later streams have higher precedence.

Compatible mappings merge recursively by YAML structural key equality. Base key order is retained, replaced values keep their position, and new overlay keys append in overlay order. Tags, complex keys, anchors, aliases, shared nodes, and recursive graphs remain representation data; values are never projected through PowerShell objects or dictionaries.

Output uses LF line endings, has no final newline, and explicitly starts every document. Input array elements and pipeline records are complete streams, not individual lines. Use Get-Content -Raw or Import-Yaml file handling as appropriate.

EXAMPLES

EXAMPLE 1

$merged = Merge-Yaml -InputObject @($baseYaml, $overlayYaml)

Merges two complete stream strings with the overlay taking precedence.

EXAMPLE 2

$baseYaml, $environmentYaml, $secretYaml | Merge-Yaml -SequenceAction Unique

Merges three complete pipeline stream records and deduplicates compatible sequence entries structurally.

EXAMPLE 3

$base = Get-Content -LiteralPath '.\base.yaml' -Raw $overlay = Get-Content -LiteralPath '.\overlay.yaml' -Raw Merge-Yaml -InputObject @($base, $overlay) -ConflictAction Error -Indent 4

Reads complete files and rejects incompatible merge conflicts.

PARAMETERS

-ConflictAction

{{ Fill ConflictAction Description }}

yaml Type: System.String DefaultValue: Replace SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-Depth

{{ Fill Depth Description }}

yaml Type: System.Int32 DefaultValue: 100 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-Indent

{{ Fill Indent Description }}

yaml Type: System.Int32 DefaultValue: 2 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-InputObject

{{ Fill InputObject Description }}

yaml Type: System.String[] DefaultValue: '' SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: 0 IsRequired: true ValueFromPipeline: true ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxAliases

{{ Fill MaxAliases Description }}

yaml Type: System.Int32 DefaultValue: 1000 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxNodes

{{ Fill MaxNodes Description }}

yaml Type: System.Int32 DefaultValue: 100000 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxNumericLength

{{ Fill MaxNumericLength Description }}

yaml Type: System.Int32 DefaultValue: 4096 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxScalarLength

{{ Fill MaxScalarLength Description }}

yaml Type: System.Int32 DefaultValue: 1048576 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxTagLength

{{ Fill MaxTagLength Description }}

yaml Type: System.Int32 DefaultValue: 1024 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-MaxTotalTagLength

{{ Fill MaxTotalTagLength Description }}

yaml Type: System.Int32 DefaultValue: 65536 SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-NullAction

{{ Fill NullAction Description }}

yaml Type: System.String DefaultValue: Replace SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

-SequenceAction

{{ Fill SequenceAction Description }}

yaml Type: System.String DefaultValue: Replace SupportsWildcards: false Aliases: [] ParameterSets: - Name: (All) Position: Named IsRequired: false ValueFromPipeline: false ValueFromPipelineByPropertyName: false ValueFromRemainingArguments: false DontShow: false AcceptedValues: [] HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String[]

The complete YAML streams to merge. Each pipeline record is parsed as one stream.

{{ Fill in the Description }}

System.String[]

{{ Fill in the Description }}

OUTPUTS

System.String

The merged YAML stream emitted from the combined representation graphs.

{{ Fill in the Description }}

System.String

{{ Fill in the Description }}

NOTES

YAML 1.1 merge keys are ordinary mapping data and are never expanded.