Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Test-OfficeYaml

Module
PSWriteOffice
Inputs
System.String[]
Outputs
System.Boolean PSWriteOffice.Models.Yaml.OfficeYamlTestResult

Tests whether YAML files or text load, without changing them.

Syntax

Test-OfficeYaml
[-Detailed]
[-Options <YamlLoadOptions>]
[-Path] <String[]>
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Strict]
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Path
Test-OfficeYaml
[-Detailed]
-LiteralPath <String[]>
[-Options <YamlLoadOptions>]
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Strict]
[-Untrusted]
[<CommonParameters>]
#
Parameter set: LiteralPath
Test-OfficeYaml
[-Detailed]
[-Options <YamlLoadOptions>]
[-Schema <Failsafe|Json|Core|Yaml11>]
[-Strict]
-Text <String>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Text

Description

Returns $true or $false for each input, as Test-Json does. Detailed returns a result with the error's diagnostic code, message, 1-based line and column, and the warnings the engine recorded while loading. Strict applies the specification's exact rules, and Untrusted the engine's limits for files from outside.

Examples

Gate a pipeline step on a valid file.

if (-not (Test-OfficeYaml -Path ./values.yaml -Strict)) { throw 'values.yaml is not valid YAML.' }

Report where every broken file fails.

Get-ChildItem ./deploy -Recurse -Filter *.yaml | Test-OfficeYaml -Detailed |
                Where-Object { -not $_.IsValid } |
                Select-Object -Property Path, Line, Column, Code, Message

Parameters

-Detailed SwitchParameter optional
Return a result with the error position and the load warnings instead of a Boolean.
-Options YamlLoadOptions optional
Native load options or a hashtable of their properties.
-Path String[] requiredposition: 0pipeline: True (ByValue)sets: Path
YAML files with FileSystem wildcard expansion.
-Schema YamlSchema optional
Forces a schema: Failsafe, Json, Core (the default) or Yaml11.
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.
-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal YAML files, including FileInfo.FullName and provider PSPath.
-Text String requiredsets: Text
YAML text to test.

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.

Outputs

PSWriteOffice.Models.Yaml.OfficeYamlTestResult: The outcome of Test-OfficeYaml -Detailed for one input.