ConvertTo-OfficeYaml
Converts PowerShell objects to YAML text, as ConvertTo-Json does for JSON.
Syntax
ConvertTo-OfficeYaml
[-Depth <Int32>]
[-InputObject] <Object>
[-WriteOptions <YamlWriterOptions>]
[<CommonParameters>]#InputObjectDescription
Hashtables, ordered dictionaries and object properties become mappings, collections become sequences and enums their names. One piped object is written as itself and several as a sequence. Objects nested deeper than Depth (default 2) are written as their string form with a warning, as ConvertTo-Json does. Strings that YAML 1.1 readers would take as another type (yes, on, 012, 1e3) are quoted.
Examples
Turn a hashtable into a configuration snippet.
[ordered]@{ name = 'web'; replicas = 3; ports = 80, 443 } | ConvertTo-OfficeYamlWrite nested service data with four-space indentation.
Get-Service | Select-Object -First 3 Name, Status, DependentServices |
ConvertTo-OfficeYaml -Depth 3 -WriteOptions @{ MappingIndent = 4; SequenceIndent = 4; SequenceDashOffset = 2 }Parameters
- -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 a sequence.
- -WriteOptions YamlWriterOptions
- Indentation and line-break settings, as a YamlWriterOptions object or hashtable.
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.