Skip to content

ConvertTo-Yaml

SYNOPSIS

Converts PowerShell values to YAML 1.2-compatible text.

SYNTAX

__AllParameterSets

powershell ConvertTo-Yaml [-InputObject] <Object> [-Depth <int>] [-MaxNodes <int>] [-MaxScalarLength <int>] [-Indent <int>] [-ExplicitDocumentStart] [-EnumsAsStrings]

ALIASES

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

DESCRIPTION

Normalizes supported PowerShell values into mappings, sequences, and scalars before emitting YAML with the module's repository-owned YAML emitter. PowerShell metadata is not serialized. Repeated acyclic references use YAML anchors and aliases; cyclic and unsupported values terminate with a specific error.

Multiple pipeline records are collected into one top-level sequence.

EXAMPLES

EXAMPLE 1

[ordered]@{ name = 'Ada'; active = $true } | ConvertTo-Yaml

Converts one mapping to YAML.

EXAMPLE 2

'one', 'two' | ConvertTo-Yaml

Converts two pipeline records to one YAML sequence.

PARAMETERS

-Depth

Cap object-graph nesting depth so deep or hostile graphs can't exhaust the stack.

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: ''

-EnumsAsStrings

Emit enum names as strings instead of their underlying numeric values.

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

-ExplicitDocumentStart

Emit an explicit --- document-start marker ahead of the content.

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

-Indent

Number of spaces per block-indentation level in the emitted YAML.

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

The value to serialize. Multiple pipeline records are collected into a single top-level YAML sequence.

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

-MaxNodes

Cap the total number of traversed nodes to bound memory and time.

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: ''

-MaxScalarLength

Cap the character count of any single emitted scalar.

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: ''

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.Object

The value to serialize. Multiple pipeline records are collected into one sequence.

{{ Fill in the Description }}

System.Object

{{ Fill in the Description }}

OUTPUTS

System.String

The YAML 1.2-compatible text emitted for the input values.

{{ Fill in the Description }}

System.String

{{ Fill in the Description }}

NOTES