Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeYamlNode

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

Sets the value at a path in a live YAML document, creating missing mappings on the way.

Syntax

Set-OfficeYamlNode
[-Document <YamlDocument>]
[-PassThru]
[-Select] <String>
[-Style <YamlStyle>]
[-Value] <Object>
[<CommonParameters>]
#
Parameter set: Document

Description

Setting a scalar over a scalar keeps its comments, anchor and tag, and an equal value keeps its original spelling, so saving changes only the text of what really changed. Hashtables, arrays and objects become mappings and sequences in the layout of their new neighbors. An index equal to a sequence's length appends.

Examples

Bump an image tag inside an editing block.

Open-OfficeYaml -Path ./values.yaml {
    Set-OfficeYamlNode -Select 'image.tag' -Value '1.27.2'
}

Add a mapping and append a sequence item.

Set-OfficeYamlNode -Document $document -Select 'resources.limits' -Value ([ordered]@{ cpu = '500m'; memory = '256Mi' })
Set-OfficeYamlNode -Document $document -Select 'ports[2]' -Value 8443

Parameters

-Document YamlDocument optionalpipeline: True (ByValue)
Gets or sets an explicit live document; omission uses the enclosing content block.
-PassThru SwitchParameter optional
Return the node that is now at the path.
-Select String requiredposition: 0
Path of the node to set; $ sets the root of the first document.
-Style YamlStyle optional
Scalar style for a string value, such as DoubleQuoted or Literal; omission picks a safe style.
Possible values: Plain, SingleQuoted, DoubleQuoted, Literal, Folded, Block, Flow
-Value Object requiredposition: 1
The new value: a scalar, hashtable, array, object or YamlNode. $null writes a YAML null.

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.