Skip to content

Export-Yaml

SYNOPSIS

Exports PowerShell values to a YAML file.

SYNTAX

__AllParameterSets

powershell Export-Yaml [-InputObject] <Object> [-Path] <string> [-Depth <int>] [-MaxNodes <int>] [-MaxScalarLength <int>] [-Indent <int>] [-ExplicitDocumentStart] [-EnumsAsStrings] [-Encoding <string>] [-NewLine <string>] [-NoFinalNewline] [-NoClobber] [-Force] [-CreateDirectory] [-PassThru] [-WhatIf] [-Confirm]

ALIASES

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

DESCRIPTION

Collects pipeline records with the same aggregation semantics as ConvertTo-Yaml, serializes the complete value before changing the filesystem, and writes strict encoded bytes through a cryptographically random same-directory temporary file.

The completed temporary file is flushed and closed before it atomically replaces or moves to the destination. Existing files are never truncated before serialization and writing succeed.

EXAMPLES

EXAMPLE 1

$config | Export-Yaml -Path '.\config.yaml'

Serializes one pipeline value to config.yaml with UTF-8 and LF.

EXAMPLE 2

'one', 'two' | Export-Yaml -Path '.\items.yaml' -Encoding utf16LE

Collects two pipeline records into one sequence and writes UTF-16LE.

EXAMPLE 3

Export-Yaml -InputObject $config -Path '.\new\config.yaml' -CreateDirectory -PassThru

Creates the parent directory and returns the final FileInfo.

PARAMETERS

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-CreateDirectory

Creates missing parent directories after approval.

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

-Depth

Limits object-graph nesting depth.

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

-Encoding

Selects strict output encoding and byte order mark policy.

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

-EnumsAsStrings

Emits enum names instead of 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

Emits an explicit YAML document start marker.

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

-Force

Permits replacement of a read-only destination.

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

Selects block indentation width.

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

Collects one value per pipeline record.

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

Limits traversed serialization nodes.

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

Limits emitted characters in one 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: ''

-NewLine

Selects structural line endings.

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

-NoClobber

Prevents replacement of an existing destination.

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

-NoFinalNewline

Omits the one final structural line ending.

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

-PassThru

Emits the final FileInfo after success.

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

-Path

Selects one literal FileSystem destination.

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

-WhatIf

Runs the command in a mode that only reports what would happen without performing the actions.

yaml Type: System.Management.Automation.SwitchParameter DefaultValue: '' SupportsWildcards: false Aliases: - wi 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.IO.FileInfo

The destination file

{{ Fill in the Description }}

System.IO.FileInfo

{{ Fill in the Description }}

NOTES

Only FileSystem provider destinations are supported.