Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Export-OfficeYaml

Module
PSWriteOffice
Inputs
System.Object
Outputs
System.IO.FileInfo

Writes PowerShell objects to a YAML file; the file form of ConvertTo-OfficeYaml.

Syntax

Export-OfficeYaml
[-Depth <Int32>]
-InputObject <Object>
[-NoClobber]
[-PassThru]
[-Path] <String>
[-WriteOptions <YamlWriterOptions>]
[<CommonParameters>]
#
Parameter set: InputObject

Description

The file is UTF-8 without a byte-order mark and is written atomically. An existing file is replaced unless NoClobber is set. To change values in an existing file while keeping its comments and layout, use Open-OfficeYaml and Set-OfficeYamlNode instead.

Examples

Save settings to a file.

[ordered]@{ logging = [ordered]@{ level = 'Information' }; retries = 3 } | Export-OfficeYaml -Path ./settings.yaml

Export an inventory without replacing an existing file.

Import-OfficeCsv -Path ./servers.csv | Export-OfficeYaml -Path ./inventory.yaml -NoClobber -PassThru

Parameters

-Depth Int32 optional
How many levels of nested objects to write; deeper values become their string form.
-InputObject Object requiredpipeline: True (ByValue)
Objects to write; an argument is written exactly as given, piped objects as one value or a sequence.
-NoClobber SwitchParameter optional
Refuse to replace an existing file.
-PassThru SwitchParameter optional
Return the written file.
-Path String requiredposition: 0
The YAML file to create.
-WriteOptions YamlWriterOptions optional
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.