@@ -29,6 +29,8 @@ The module exports:
2929| --- | --- |
3030| ` ConvertFrom-Yaml ` | Parse one or more YAML documents into PowerShell values. |
3131| ` ConvertTo-Yaml ` | Serialize supported PowerShell values as YAML 1.2-compatible text. |
32+ | ` Export-Yaml ` | Serialize values and atomically write one YAML file. |
33+ | ` Import-Yaml ` | Strictly decode and parse YAML files. |
3234| ` Test-Yaml ` | Test YAML syntax, tags, duplicate keys, and configured resource limits. |
3335
3436## Parse YAML
@@ -84,6 +86,24 @@ $mapping = @'
8486'@ | ConvertFrom-Yaml -AsHashtable
8587```
8688
89+ ## Import YAML files
90+
91+ ` Import-Yaml ` reads complete files with strict Unicode decoding and delegates
92+ parsing to ` ConvertFrom-Yaml ` . ` -Path ` expands wildcards and accepts ` FileInfo `
93+ pipeline input; ` -LiteralPath ` preserves wildcard characters in filenames.
94+ Resolved files are deduplicated and read in deterministic path order.
95+
96+ ``` powershell
97+ $configs = Import-Yaml -Path '.\config\*.yaml' -AsHashtable
98+ Get-ChildItem -Path '.\services' -Filter '*.yaml' | Import-Yaml
99+ Import-Yaml -LiteralPath '.\config[production].yaml'
100+ ```
101+
102+ UTF-8 without a byte order mark is the default. UTF-8, UTF-16, and UTF-32 byte
103+ order marks are detected automatically and override ` -Encoding ` . Malformed
104+ bytes terminate with a path-specific error. ` -NoEnumerate ` and all parser
105+ resource limits have the same behavior as ` ConvertFrom-Yaml ` .
106+
87107## Serialize PowerShell values
88108
89109` ConvertTo-Yaml ` supports ` PSCustomObject ` and explicit PSObject note-property
@@ -123,6 +143,25 @@ Repeated acyclic collection references are emitted with anchors and aliases.
123143Cyclic graphs and unsupported runtime objects fail specifically; values are
124144never silently truncated or converted with ` ToString() ` .
125145
146+ ## Export YAML files
147+
148+ ` Export-Yaml ` aggregates pipeline records like ` ConvertTo-Yaml ` , serializes the
149+ complete value before changing the filesystem, and atomically publishes a
150+ same-directory temporary file. It writes UTF-8 without a byte order mark, LF
151+ line endings, and exactly one final newline by default.
152+
153+ ``` powershell
154+ $config | Export-Yaml -Path '.\config.yaml'
155+ 'one', 'two' | Export-Yaml -Path '.\items.yaml' -Encoding utf16LE
156+ $config | Export-Yaml -Path '.\generated\config.yaml' -CreateDirectory -PassThru
157+ ```
158+
159+ Use ` -NewLine CRLF ` or ` -NoFinalNewline ` to change presentation. ` -NoClobber `
160+ prevents replacement, while ` -Force ` permits replacing a read-only destination
161+ and preserves its read-only state. The switches are mutually exclusive.
162+ ` -WhatIf ` creates no directory or temporary file. ` -PassThru ` is the only mode
163+ that emits the final ` FileInfo ` .
164+
126165## Validate YAML
127166
128167``` powershell
0 commit comments