ConvertTo-OfficeToml
Converts PowerShell objects to TOML text, as ConvertTo-Json does for JSON.
Syntax
ConvertTo-OfficeToml
[-Depth <Int32>]
[-InputObject] <Object>
[-RootName <String>]
[<CommonParameters>]#InputObjectDescription
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-OfficeTomlWrite a list of records as an array of tables.
Get-Process | Select-Object -First 3 Name, Id | ConvertTo-OfficeToml -RootName processParameters
- -Depth Int32
- How many levels of nested objects to write; deeper values become their string form.
- -InputObject Object
- Objects to convert; an argument is written exactly as given, piped objects as one value or an array.
- -RootName String
- 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.