Functions/Get-CMCFNParameters.ps1
function Get-CMCFNParameters { [OutputType([String])] [CmdletBinding()] Param ( [Parameter(Mandatory=$true)] [String] $Template, [ValidateSet("YAML", "JSON")] [String] $Format = "YAML" ) if ($Format -eq "YAML"){ if (-not (Get-Command ConvertFrom-Yaml)){ Write-error "ConvertFrom-Yaml not found, please make sure the FXPSYaml module is installed" } } $Text = @('$Parameters = @(') Try { $Parameters = [PSCustomObject]($Template | ConvertFrom-Yaml).Parameters } Catch { $Parameters = [PSCustomObject]($Template | ConvertFrom-Json).Parameters } If ($Parameters){ foreach ($Param in ($Parameters | Get-Member | Where MemberType -eq "NoteProperty").Name) { $Text+=' @{ParameterKey="'+$Param+'"; ParameterValue="'+$($Parameters.$Param.Default)+'"}' } } $Text+=')' $Text | Out-String } |