Very interesting, thank you. One last question, do you know 
if "environment_vars":[] are accessible from the execute command? If so, 
maybe i could just stick scriptTargetPath there and call it with 
$env:scriptTargetPath?

On Thursday, January 24, 2019 at 3:12:01 PM UTC-8, Megan Marsh wrote:
>
> Off the top of my head, it would look something like this, but you may 
> have to tinker to get it working. I don't think your scriptTargetPath 
> variable will be properly interpolated inside of the execute_command 
> option, unfortunately, so you may have to hardcode the path.
>
>        {
>             "type": "powershell",
>             "elevated_user": "{{user `admin_username` }}",
>             "elevated_password": "{{.WinRMPassword}}",
>             "execute_command": "powershell -executionpolicy bypass \"& 
> {Set-Location -Path C:\\artifacts\\windows-netfx3;. {{.Vars}}; 
> &'{{.Path}}'; exit $LastExitCode }\""
>             "inline": [
>                 "{{user 
> `scriptTargetPath`}}\\artifacts\\windows-netfx3\\windows-netfx3.ps1"
>             ]
>         }
>
> On Thu, Jan 24, 2019 at 3:03 PM goffries <[email protected] <javascript:>> 
> wrote:
>
>> Would you happen to have an example?
>>
>> Like if i wanted to run this art of the windows-netfx3 folder?
>>
>>         {
>>             "type": "powershell",
>>             "elevated_user": "{{user `admin_username` }}",
>>             "elevated_password": "{{.WinRMPassword}}",
>>             "inline": [
>>                 "& {{user 
>> `scriptTargetPath`}}\\artifacts\\windows-netfx3\\windows-netfx3.ps1"
>>             ]
>>         }
>>
>>
>>
>> On Thursday, January 24, 2019 at 2:56:46 PM UTC-8, Megan Marsh wrote:
>>>
>>> You can probably use the `execute_command` option to have Packer change 
>>> directories to the one you want to execute from.
>>>
>>> On Thu, Jan 24, 2019 at 2:32 PM goffries <[email protected]> wrote:
>>>
>>>> Is there a way to set the working directory that packer executes a 
>>>> script from? Ideally I'd like to to run the script out of the folder that 
>>>> the script is in.
>>>>
>>>> -- 
>>>> 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/462c1af2-f15c-490b-824a-c60d8d4512ac%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/packer-tool/462c1af2-f15c-490b-824a-c60d8d4512ac%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/748b8b3b-d771-4b9f-94d7-b60f12048750%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/748b8b3b-d771-4b9f-94d7-b60f12048750%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/77393ef6-8468-4a01-8272-037db293adb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to