Functions/New-ARMparameter.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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
#Requires -Version 5.0 function New-ARMparameter { <# .SYNOPSIS Create a new ARM template parameter .DESCRIPTION Create a new ARM template parameter .PARAMETER Name The name of the parameter. This is Mandatory .PARAMETER Type The parameter type. Allowed values are "string","secureString","int","bool","object","secureObject","array" .EXAMPLE New-ARMparameter -Name adminUsername -Type String This will create a new parameter named adminUsername of type String .EXAMPLE $AllowedValues = @{ AllowedValues = "2008-R2-SP1","2012-Datacenter","2012-R2-Datacenter","2016-Nano-Server","2016-Datacenter-with-Containers","2016-Datacenter" } New-ARMparameter -Name windowsOSVersion -Type String -DefaultValue "2016-Datacenter" @allowedValues This will create a new parameter named windowsOSVersion of type String, with a default value of "2016-Datacenter" which is in the allowedValues list/array .INPUTS String .OUTPUTS PSCustomObject .NOTES Author: Tore Groneng Website: www.firstpoint.no Twitter: @ToreGroneng #> [cmdletbinding()] Param( [Parameter(Mandatory)] [string] $Name , [Parameter(Mandatory)] [ValidateSet("string","secureString","int","bool","object","secureObject","array")] [string] $Type , $DefaultValue , $AllowedValues , $MinValue , $MaxValue , $MinLength , $MaxLength , $Description , $Metadata ) $propHash = [ordered]@{ type = $Type } if ($DefaultValue) { $null = $propHash.defaultValue = $DefaultValue } if ($AllowedValues) { $null = $propHash.allowedValues = $AllowedValues } if ($MinValue) { $null = $propHash.minValue = $MinValue } if ($MaxValue) { $null = $propHash.maxValue = $MaxValue } if ($MinLength) { $null = $propHash.minLength = $MinLength } if ($MaxLength) { $null = $propHash.maxLength = $MaxLength } if ($Description) { Write-Verbose -Message "Adding description" $null = $propHash.metadata = @{description = $Description} } if ($Metadata) { $null = $propHash.metadata += $Metadata } $out = [PSCustomobject]@{ PSTypeName = "ARMparameter" $Name = [PSCustomobject]$propHash } $out } |