Private/Test-ParameterValue.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
function Test-ParameterValue { <# .SYNOPSIS Checks the type of Blueprint Parameter .DESCRIPTION Determines the type of Blueprint Parameter and returns a description of what the Azure DevOps variable requires as a value. .PARAMETER Value A PSCustomObject containing the Blueprint Parameter information .EXAMPLE Test-ParameterValue ` -Value [PSCustomObject]@{ type = "string" metadata = [PSCustomObject]@{displayName = "app_tshirt-size (WebApp Template)"; description = "What T-Shirt size is required for the Web App"} defaultValue = "Medium" allowedValues = @("Small", "Medium", "Large") } #> param ( [Parameter(Mandatory=$true)] [PSCustomObject]$Value ) switch ($Value.type) { "array" { $tmpValue = "Needs to be an Array e.g. value1,value2,etc." } "object" { $tmpValue = "Needs to be an Object, but as JSON e.g. '{`"key1`": `"value1`", `"key2`": `"value2`"}'" } "int" { $tmpValue = "Needs to be an Int i.e. Integer/Number e.g. 123 etc." } "secureString" { $tmpValue = "Needs to be ReferenceId to a password in a Key Vault e.g. /subscriptions/`$(subscriptionId)/resourceGroups/`$(keyVault.ResourceGroup)/providers/Microsoft.KeyVault/vaults/`$(keyVault),`$(BP_activedirectorydomainservices_addomainadminusername)." } "string" { $tmpValue = "Needs to be an String or Text e.g. This is Text etc." } "resourceGroup" { $tmpValue = "Needs to be an Object, but as JSON e.g. '{`"name`": `"ResourceGroupName`", `"location`": `"azureregion`"}'" } default { $tmpValue = "" } } return $tmpValue } |