Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Import-OfficeYaml

Module
PSWriteOffice
Inputs
System.String[]
Outputs
System.Management.Automation.PSObject System.Collections.Specialized.OrderedDictionary System.Object[]

Reads YAML files as PowerShell objects; the file form of ConvertFrom-OfficeYaml.

Syntax

Import-OfficeYaml
[-AllDocuments]
[-AsHashtable]
[-Depth <Int32>]
[-NoEnumerate]
[-Path] <String[]>
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Strict]
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Path
Import-OfficeYaml
[-AllDocuments]
[-AsHashtable]
[-Depth <Int32>]
-LiteralPath <String[]>
[-NoEnumerate]
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Strict]
[-Untrusted]
[<CommonParameters>]
#
Parameter set: LiteralPath

Description

The encoding (UTF-8, UTF-16 or UTF-32) is detected from the file. Output follows ConvertFrom-OfficeYaml: mappings become PSCustomObjects in file order, or ordered hashtables with AsHashtable. A file that fails to parse writes a non-terminating error with the engine's code, line and column, and the next file is read.

Examples

Read a settings file.

$settings = Import-OfficeYaml -Path ./settings.yaml
$settings.logging.level

List the kinds in every manifest under a folder.

Get-ChildItem ./deploy -Filter *.yaml | Import-OfficeYaml -AllDocuments | Group-Object kind

Parameters

-AllDocuments SwitchParameter optional
Read every document of a multi-document file; without it, more than one document is an error.
-AsHashtable SwitchParameter optional
Return mappings as ordered hashtables instead of PSCustomObjects.
-Depth Int32 optional
Deepest nesting of mappings and sequences to accept; sets the reader's MaxDepth.
-NoEnumerate SwitchParameter optional
Write a root sequence as one array instead of enumerating its items.
-Path String[] requiredposition: 0pipeline: True (ByValue)sets: Path
YAML files with FileSystem wildcard expansion.
-Schema YamlSchema optional
Schema for scalar types: Core (the default), Json, Yaml11, or Failsafe to keep every scalar a string.
Possible values: Failsafe, Json, Core, Yaml11
-Strict SwitchParameter optional
Applies the YAML specification's exact rules instead of accepting common real-world leniencies.
-Untrusted SwitchParameter optional
Caps every limit at the engine's untrusted defaults, for files from outside.
-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal YAML files, including FileInfo.FullName and provider PSPath.

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.