Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Save-OfficeYaml

Module
PSWriteOffice
Inputs
OfficeIMO.Yaml.YamlDocument
Outputs
System.IO.FileInfo

Saves a live YAML document and keeps it available.

Syntax

Save-OfficeYaml
-Document <YamlDocument>
[-PassThru]
[[-Path] <String>]
[-WriteOptions <YamlSaveOptions>]
[<CommonParameters>]
#
Parameter set: Document

Description

The default save is minimal-change: untouched text is copied from the source, in the encoding and byte-order mark it was loaded with, and only edited nodes are written anew. WriteOptions with Reformat rewrites the whole document through the writer.

Examples

Save to the file the document was opened from.

Save-OfficeYaml -Document $document

Write a reformatted copy with four-space mappings.

Save-OfficeYaml -Document $document -Path ./out/values.yaml -WriteOptions @{ Reformat = $true; WriterOptions = [OfficeIMO.Yaml.YamlWriterOptions]@{ MappingIndent = 4 } } -PassThru

Parameters

-Document YamlDocument requiredpipeline: True (ByValue)
YAML document to save.
-PassThru SwitchParameter optional
Return the saved file.
-Path String optionalposition: 0
Optional destination, which becomes the document's FilePath; omission saves to its FilePath.
-WriteOptions YamlSaveOptions optional
Native save settings or a hashtable of their properties.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.