Format-Yaml¶
SYNOPSIS¶
Normalizes a YAML stream without projecting it to PowerShell values.
SYNTAX¶
__AllParameterSets¶
powershell
Format-Yaml [-InputObject] <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 YAML into the module's representation graph and emits one deterministic YAML string directly from those nodes. Document order, empty documents, effective tags, anchors, aliases, complex keys, node kinds, scalar content, and mapping order are preserved.
Comments, directives, flow styles, scalar presentation styles, document end markers, and source anchor names are normalized. Every document has an explicit start marker. Output uses LF and has no final newline.
Pipeline strings are joined with a line feed and parsed as one stream, matching ConvertFrom-Yaml.
EXAMPLES¶
EXAMPLE 1¶
Get-Content -Path '.\config.yaml' | Format-Yaml
Joins the input lines and emits one normalized YAML stream.
EXAMPLE 2¶
$normalized = Format-Yaml -InputObject '{name: Ada, active: true}' -Indent 4
Converts flow presentation to deterministic block presentation with four-space indentation.
PARAMETERS¶
-Depth¶
Cap YAML node nesting depth so hostile input 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: ''
-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 YAML text to normalize. Multiple pipeline records are joined with a line feed and parsed as a single stream, matching ConvertFrom-Yaml.
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¶
Cap alias nodes to prevent alias-expansion amplification.
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¶
Cap the total node count to bound memory for a single stream.
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¶
Cap the digit count of an implicitly or explicitly typed number.
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¶
Cap decoded characters per scalar to bound per-node memory.
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¶
Cap expanded characters for a single tag.
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¶
Cap cumulative expanded tag characters across the stream.
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: ''
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 YAML text to normalize. Multiple pipeline records are joined with a line feed.
{{ Fill in the Description }}
System.String[]¶
{{ Fill in the Description }}
OUTPUTS¶
System.String¶
The normalized YAML stream emitted from the representation graph.
{{ Fill in the Description }}
System.String¶
{{ Fill in the Description }}