Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Open-OfficeYaml

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

Opens a YAML file, stream or text as a lossless live document; a file content block saves atomically.

Syntax

Open-OfficeYaml
[[-Content] <ScriptBlock>]
[-Options <YamlLoadOptions>]
[-PassThru]
[-Path] <String>
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Show]
[-Strict]
[-Untrusted]
[-WriteOptions <YamlSaveOptions>]
[<CommonParameters>]
#
Parameter set: Path
Open-OfficeYaml
[[-Content] <ScriptBlock>]
-LiteralPath <String>
[-Options <YamlLoadOptions>]
[-PassThru]
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Show]
[-Strict]
[-Untrusted]
[-WriteOptions <YamlSaveOptions>]
[<CommonParameters>]
#
Parameter set: LiteralPath
Open-OfficeYaml
[-Options <YamlLoadOptions>]
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Strict]
-Text <String>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Text
Open-OfficeYaml
[-Options <YamlLoadOptions>]
[-Schema <Failsafe|Json|Core|Yaml11>]
-Stream <Stream>
[-Strict]
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Stream

Description

Saving writes only what changed: comments, blank lines, quoting and indentation outside the edited nodes stay byte for byte. Malformed input fails with a diagnostic error ID (for example yaml-syntax-unexpected-token), and the message gives the line, column and offending source line.

Examples

Change one value and keep the rest of the file as it was.

Open-OfficeYaml -Path ./deployment.yaml {
    Set-OfficeYamlNode -Select 'spec.replicas' -Value 3
}

Read an uploaded file with untrusted limits.

$document = Open-OfficeYaml -LiteralPath ./uploads/values.yaml -Untrusted -Strict
Get-OfficeYamlNode -Document $document -Select 'image.tag'
Close-OfficeYaml -Document $document

Parameters

-Content ScriptBlock optionalposition: 1sets: Path, LiteralPath
An optional editing block; omission returns the live document.
-Options YamlLoadOptions optional
Native load options or a hashtable of their properties: limits, schema, strictness and duplicate keys.
-PassThru SwitchParameter optionalsets: Path, LiteralPath
Emit the FileInfo after a completed editing block.
-Path String requiredposition: 0pipeline: True (ByValue)sets: Path
YAML file with FileSystem wildcard expansion.
-Schema YamlSchema optional
Forces a schema for typed values: Failsafe, Json, Core (the default) or Yaml11.
Possible values: Failsafe, Json, Core, Yaml11
-Show SwitchParameter optionalsets: Path, LiteralPath
Open the saved file after a completed editing block.
-Strict SwitchParameter optional
Applies the YAML specification's exact rules instead of accepting common real-world leniencies.
-Untrusted SwitchParameter optional
Caps every limit at the engine's untrusted defaults, for files from outside.
-WriteOptions YamlSaveOptions optionalsets: Path, LiteralPath
Native save settings used when an editing block saves; omission writes a minimal-change save.
-LiteralPath String requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal YAML file, including FileInfo.FullName and provider PSPath.
-Text String requiredsets: Text
YAML text to parse without a file.
-Stream Stream requiredsets: Stream
A readable stream, read from its current position; it stays open.

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.