title: Send variable number of key value pairs from CLI
body: <p>I'm needing to execute a PowerShell script as part of my TFS build pipeline. The PowerShell script is generic and executes a given AWS Cloud Formation template given to it. I need the developer to supply the template with a list of key/value pairs that represent the templates parameters. Since they can use this to execute any Cloud Formation template, the input parameters will vary.</p>
  
  <p>How can I create an input parameter that is key/value based that I can pass as a parameter to another PowerShell object that accepts a Hashmap of parameters?</p>
  
  <p>The following pseudo code is what I'm trying to achieve</p>
  
  <pre><code>param(
      [Parameter(Mandatory=$true)][string]$environment,
      [KeyValuePair[]]$templateParameters
  )
  New-CFNStack -StackName $stackName -TemplateURL $fullTemplateUrlPath -Parameters @( $templateParameters)
  </code></pre>
  
  <p>I can explicitly create the parameters and pass them in like this:</p>
  
  <pre><code>$bucketNameParameter = new-object Amazon.CloudFormation.Model.Parameter
  $bucketNameParameter.ParameterKey = "bucketname"
  $bucketNameParameter.ParameterValue = "FooBar"
  $isVersionedParameter = new-object Amazon.CloudFormation.Model.Parameter
  $isVersionedParameter.ParameterKey = "bucketname"
  $isVersionedParameter.ParameterValue = "FooBar"
  New-CFNStack -StackName $stackName -TemplateURL $fullTemplateUrlPath -Parameters @( $environmentParameter, @isVersionedParameter )
  </code></pre>
  
  <p>Since each template has completely different parameters they can take, I would like to make this script flexible to facilitate re-use. What is the most PowerShell way of approaching that?</p>