Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

ConvertTo-OfficeToml

Module
PSWriteOffice
Inputs
System.Object
Outputs
System.String

Converts PowerShell objects to TOML text, as ConvertTo-Json does for JSON.

Syntax

ConvertTo-OfficeToml
[-Depth <Int32>]
[-InputObject] <Object>
[-RootName <String>]
[<CommonParameters>]
#
Parameter set: InputObject

Description

Hashtables, ordered dictionaries and object properties become tables: nested objects are written as [table] sections and lists of objects as [[array]] sections, after the table's own values. Collections become arrays, DateTime and DateTimeOffset TOML date-times, and enums their names. TOML has no null, so nulls are omitted with a warning, and input that is not an object (such as several piped objects) is written under RootName. Objects nested deeper than Depth (default 2) are written as their string form with a warning.

Examples

Turn a hashtable into a configuration file's text.

[ordered]@{ name = 'web'; port = 8080; tls = [ordered]@{ enabled = $true } } | ConvertTo-OfficeToml

Write a list of records as an array of tables.

Get-Process | Select-Object -First 3 Name, Id | ConvertTo-OfficeToml -RootName process

Parameters

-Depth Int32 optional
How many levels of nested objects to write; deeper values become their string form.
-InputObject Object requiredposition: 0pipeline: True (ByValue)
Objects to convert; an argument is written exactly as given, piped objects as one value or an array.
-RootName String optional
The key that holds input which is not an object, because a TOML document is a table.

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.