The value you put in the variables block is just a default, you can pass a 
value for the variable when you run the packer build. You can pass values 
on the command line with the var flag or put them in a file and refer to 
the file with the var-file flag on the command line.

Then in your template code you use the variable values with the user 
function {{user `varable`}}, so the line in your template code would be

"Start-Process -FilePath \"C:\\atmp\\vs_enterprise.exe\" -ArgumentList 
\"--add Microsoft.VisualStudio.Workload.Azure --productKey {{user 
`key_info`}} --quiet\" -NoNewWindow -Wait"

This is all explained in the documentation here:
https://www.packer.io/docs/templates/user-variables.html



On Friday, November 8, 2019 at 2:39:06 PM UTC-6, Christopher Campbell wrote:
>
> Hi all, wanted to see if there is an easy way to use variables in 
> powershell provisioner.
>
> currently i have variable declared as the following and want to replace 
> the [[key]] to be the variable but i am unable to find any examples on how 
> to do this.
>
> "variables":{
>  "key_info": "1234567890"
> }
>
>
>       "type": "powershell",
>       "inline": [
>         
>         "Start-Process -FilePath \"C:\\atmp\\vs_enterprise.exe\" 
> -ArgumentList \"--add Microsoft.VisualStudio.Workload.Azure --productKey 
> [[key]] --quiet\" -NoNewWindow -Wait"
>
>
>       ]
>     },
>
>
>
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/eadfc3a6-e51f-4082-867d-4ebf8cd9ca25%40googlegroups.com.

Reply via email to