Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Get-OfficeYamlNode

Module
PSWriteOffice
Inputs
OfficeIMO.Yaml.YamlDocument
Outputs
System.Management.Automation.PSObject

Gets nodes of a live YAML document by path, as Path, Value, Node, Line and Column objects.

Syntax

Get-OfficeYamlNode
[-AsHashtable]
[-Document <YamlDocument>]
[[-Select] <String[]>]
[<CommonParameters>]
#
Parameter set: Document

Description

Select uses the engine's path grammar: dotted keys, [n] for 0-based sequence items, ["key.with.dots"] for keys that are not plain names, and a leading $[n] for the 0-based document in a multi-document stream. Value holds plain PowerShell data as ConvertFrom-OfficeYaml returns it; Node is the live node. Line and Column are 1-based. Without Select, each document's root is returned.

Examples

Read one value.

(Get-OfficeYamlNode -Document $document -Select 'spec.template.spec.containers[0].image').Value

Find where settings live in the file.

Get-OfficeYamlNode -Document $document -Select 'spec.replicas', 'metadata.labels["app.kubernetes.io/name"]' |
                Select-Object -Property Path, Value, Line, Column

Parameters

-AsHashtable SwitchParameter optional
Return mappings in Value as ordered hashtables instead of PSCustomObjects.
-Document YamlDocument optionalpipeline: True (ByValue)
Gets or sets an explicit live document; omission uses the enclosing content block.
-Select String[] optionalposition: 0
Paths of the nodes to get; omission returns each document's root.

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.