Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeTomlNode

Module
PSWriteOffice
Inputs
OfficeIMO.Toml.TomlDocument
Outputs
System.Management.Automation.PSObject

Sets the value at a path in a live TOML document, adding missing tables on the way.

Syntax

Set-OfficeTomlNode
[-Document <TomlDocument>]
[-PassThru]
[-Select] <String>
[-Value] <Object>
[<CommonParameters>]
#
Parameter set: Document

Description

Setting a value over a value changes only its text, and an equal value keeps its original spelling, so saving changes only what really changed. A new key is written after its table's last key in the indentation and spacing of its neighbors; a missing table gets a [header] section. Hashtables and objects become inline tables, and arrays become arrays. TOML has no null, so $null is an error and nulls inside a value are omitted with a warning. An index equal to an array's length appends.

Examples

Bump a version inside an editing block.

Open-OfficeToml -Path ./Cargo.toml {
    Set-OfficeTomlNode -Select 'package.version' -Value '0.4.0'
}

Add an inline table and replace an array item.

Set-OfficeTomlNode -Document $document -Select 'dependencies.serde' -Value ([ordered]@{ version = '1'; features = @('derive') })
Set-OfficeTomlNode -Document $document -Select 'project.dependencies[0]' -Value 'httpx>=0.27'

Parameters

-Document TomlDocument 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 key or array item to set.
-Value Object requiredposition: 1
The new value: a string, number, Boolean, date, hashtable, array or object.

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.