scripts/Normalize-Yaml.ps1
function Normalize-Yaml { [CmdletBinding()] param ( [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline= $true)] [string]$path ) process { $ErrorActionPreference = "Stop" try { $path = Resolve-Path $path return Get-Content $path -Raw | ConvertFrom-Yaml } catch [YamlDotNet.Core.YamlException] { throw "File '$path' is corrupted: $($_.Exception.InnerException.ToString().Split("`n")[0])" } } } |