Cmdlet
Open-OfficeYaml
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:
PathOpen-OfficeYaml
[[-Content] <ScriptBlock>]
-LiteralPath <String>
[-Options <YamlLoadOptions>]
[-PassThru]
[-Schema <Failsafe| Json| Core| Yaml11>]
[-Show]
[-Strict]
[-Untrusted]
[-WriteOptions <YamlSaveOptions>]
[<CommonParameters>]#Parameter set:
LiteralPathOpen-OfficeYaml
[-Options <YamlLoadOptions>]
[-Schema <Failsafe| Json| Core| Yaml11>]
[-Strict]
-Text <String>
[-Untrusted]
[<CommonParameters>]#Parameter set:
TextOpen-OfficeYaml
[-Options <YamlLoadOptions>]
[-Schema <Failsafe| Json| Core| Yaml11>]
-Stream <Stream>
[-Strict]
[-Untrusted]
[<CommonParameters>]#Parameter set:
StreamDescription
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 $documentParameters
- -Content ScriptBlock
- An optional editing block; omission returns the live document.
- -Options YamlLoadOptions
- Native load options or a hashtable of their properties: limits, schema, strictness and duplicate keys.
- -PassThru SwitchParameter
- Emit the FileInfo after a completed editing block.
- -Path String
- YAML file with FileSystem wildcard expansion.
- -Schema YamlSchema
- Forces a schema for typed values: Failsafe, Json, Core (the default) or Yaml11.
- Possible values:
Failsafe,Json,Core,Yaml11 - -Show SwitchParameter
- Open the saved file after a completed editing block.
- -Strict SwitchParameter
- Applies the YAML specification's exact rules instead of accepting common real-world leniencies.
- -Untrusted SwitchParameter
- Caps every limit at the engine's untrusted defaults, for files from outside.
- -WriteOptions YamlSaveOptions
- Native save settings used when an editing block saves; omission writes a minimal-change save.
- -LiteralPath String
- Literal YAML file, including FileInfo.FullName and provider PSPath.
- -Text String
- YAML text to parse without a file.
- -Stream 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.