Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficeToml

Module
PSWriteOffice
Inputs
None
Outputs
System.IO.FileInfo OfficeIMO.Toml.TomlDocument

Creates a live TOML document, or atomically publishes a completed content block.

Syntax

New-OfficeToml
[-Force]
[[-Path] <String>]
[<CommonParameters>]
#
Parameter set: Live
New-OfficeToml
[-AllowLoss]
[-Content] <ScriptBlock>
[-Force]
[-PassThru]
[-Path] <String>
[-Show]
[<CommonParameters>]
#
Parameter set: Content

Description

Inside the block, Set-OfficeTomlNode and the other node commands edit the new document without -Document. Setting a key below a missing table adds the table's [header] section.

Examples

Write a project file in one block.

New-OfficeToml -Path ./pyproject.toml {
    Set-OfficeTomlNode -Select 'project.name' -Value 'reporting'
    Set-OfficeTomlNode -Select 'tool.ruff.line-length' -Value 100
}

Compose a live document and save it later.

$document = New-OfficeToml
Set-OfficeTomlNode -Document $document -Select 'title' -Value 'Release notes'
Save-OfficeToml -Document $document -Path ./config.toml
Close-OfficeToml -Document $document

Parameters

-Force SwitchParameter optional
Allow an existing destination; a failed block preserves its original contents.
-Path String required in Contentposition: 0aliases: FilePath
Optional associated destination for a live document; required when a content block saves a file.
-AllowLoss SwitchParameter optionalsets: Content
Explicitly accept reductions reported by the content block's native save.
-Content ScriptBlock requiredposition: 1sets: Content
Authoring block to complete before the document is atomically saved and closed.
-PassThru SwitchParameter optionalsets: Content
Return the saved FileInfo after a completed content block.
-Show SwitchParameter optionalsets: Content
Open the saved result in its registered application after the content block succeeds.

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.