Cmdlet
Set-OfficeYamlNode
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:
DocumentDescription
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 8443Parameters
- -Document YamlDocument
- Gets or sets an explicit live document; omission uses the enclosing content block.
- -PassThru SwitchParameter
- Return the node that is now at the path.
- -Select String
- Path of the node to set; $ sets the root of the first document.
- -Style YamlStyle
- 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
- 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.