Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

New-OfficeYaml

Module
PSWriteOffice
Inputs
None
Outputs
System.IO.FileInfo OfficeIMO.Yaml.YamlDocument

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

Syntax

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

Description

Inside the block, Set-OfficeYamlNode and the other node commands edit the new document without -Document.

Examples

Write a configuration file in one block.

New-OfficeYaml -Path ./service.yaml {
    Set-OfficeYamlNode -Select 'name' -Value 'web'
    Set-OfficeYamlNode -Select 'spec.replicas' -Value 3
}

Compose a live document and save it later.

$document = New-OfficeYaml
Set-OfficeYamlNode -Document $document -Select 'image' -Value 'nginx:1.27'
Save-OfficeYaml -Document $document -Path ./values.yaml
Close-OfficeYaml -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.
-WriteOptions YamlSaveOptions optionalsets: Content
Native YAML save settings or a hashtable, used when publishing a block.

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.