Yeah, I know about execute command, but actually I didn't realise that it doesn't have to be an actual script it tries to run its just runs it to inject environment variables. Now everything makes sense after I saw what you are doing on Linux. I'm a Linux person as well so windows is a very new area for me (hating it already :P).
Thanks very much!
Yeah, for PowerShell out of the box it should work:
documenation state:
environment_vars (array of strings) - An array of key/value pairs to
inject prior to the execute_command. The format should be key=value.
Packer injects some environmental variables by default into the
environment, as well, which are covered in the section below.
execute_command (string) - The command to use to execute the script.
By default this is powershell "& { {{.Vars}}{{.Path}}; exit
$LastExitCode}". The value of this is treated as configuration
template. There are two available variables: Path, which is the path
to the script to run, and Vars, which is the list of environment_vars,
if configured.
Can you share a sample reproductable case in the bug? that will help
the review of the same.