diff --git a/src/ALZ/Private/Get-ALZConfig.ps1 b/src/ALZ/Private/Get-ALZConfig.ps1 index 8ec6054e..2e75c0ae 100644 --- a/src/ALZ/Private/Get-ALZConfig.ps1 +++ b/src/ALZ/Private/Get-ALZConfig.ps1 @@ -15,7 +15,19 @@ function Get-ALZConfig { # Import the config from the json file inside assets and transform it to a PowerShell object if ($configFilePath -ne "") { - $config = Get-Content -Path $configFilePath | ConvertFrom-Json + $extension = (Get-Item -Path $configFilePath).Extension.ToLower() + if($extension -eq ".yml" -or $extension -eq ".yaml") { + if (!(Get-Module -ListAvailable -Name powershell-Yaml)) { + Write-Host "Installing YAML module" + Install-Module powershell-Yaml -Force + } + $config = [PSCustomObject](Get-Content -Path $configFilePath | ConvertFrom-Yaml) + } elseif($extension -eq ".json") { + $config = Get-Content -Path $configFilePath | ConvertFrom-Json + } else { + throw "The config file must be a json or yaml/yml file" + } + return $config }