Unable to create Virtualbox Windows 8 and 2012 boxes.

76 views
Skip to first unread message

Wil T

unread,
Mar 27, 2017, 12:54:21 AM3/27/17
to Packer
I get the following error anytime I try to call any elevated powershell script from a provisioner with Windows 8 and 2012 vms.  

Error:
==> virtualbox-iso: Connected to WinRM!
==> virtualbox-iso: Uploading VirtualBox version info (5.1.18)
==> virtualbox-iso: Provisioning with Powershell...
==> virtualbox-iso: Provisioning with shell script: C:\Users\vagrant\AppData\Local\Temp\packer-powershell-provisioner029272611
    virtualbox-iso: Exception calling "Run" with "1" argument(s): "Could not load file or assembly
    virtualbox-iso: 'Microsoft.PowerShell.Commands.Management' or one of its dependencies. The
    virtualbox-iso: system cannot find the file specified."
    virtualbox-iso: At C:\Users\vagrant\AppData\Local\Temp\packer-elevated-shell-58d88da0-926d-aa38
    virtualbox-iso: -4744-6d53beaecfa5.ps1:51 char:1
    virtualbox-iso: + $t.Run($null) | Out-Null
    virtualbox-iso: + ~~~~~~~~~~~~~~~~~~~~~~~~
    virtualbox-iso: + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    virtualbox-iso: + FullyQualifiedErrorId : ComMethodTargetInvocation
    virtualbox-iso:
==> virtualbox-iso: Unregistering and deleting virtual machine...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Script exited with non-zero exit status: 1. Allowed exit codes are: [0 3010]

What I have tried:
* If I use the same scripts on Windows 7, 8.1, 10, 2008R2, 2012R2 or 2016 it works as expected.
* Tried a different script on 8 and get the above problem.
* Tried not elevating script... error doesn't appear but I need to run elevation for Windows patching.
* Tried rebooting before running scripts.
* Tried to installing .net 3.5 features.






Alvaro Miranda Aguilera

unread,
Mar 27, 2017, 6:53:48 AM3/27/17
to packe...@googlegroups.com

On Mon, Mar 27, 2017 at 6:54 AM, Wil T <wilfri...@gmail.com> wrote:
:51

What are the lines around 49-53
?



--
Alvaro


Virusvrij. www.avast.com

Wil Taylor

unread,
Mar 27, 2017, 7:20:25 AM3/27/17
to packe...@googlegroups.com
Hi Alvaro,
It looks like it is part of the script that Packer uses to elevate my script via windows task manager.

I was able to debug the machine and look at the script. I was able to grab a screenshot of the packer generated script:


pasted1

pasted2
I tried manually running this script and I get the same error.
--
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 a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/QKlsgxYqUSY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0eyhDweamTVifjA11Nn3iwX-qzUXsPxEsv%3D%2BB0DMkG4aww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Joshua H.

unread,
Jun 14, 2017, 12:59:06 PM6/14/17
to Packer
I too am getting the exact same error with Server 2012. I'm not sure exactly what the issue is, or how to work around it. This is with Packer 1.0.0.

I don't understand why Packer is trying to use the Task Scheduler to run PowerShell scripts in the first place. Why doesn't it just upload the script and execute?

The OP said not elevating the script seems to work, so I will give that a shot, but that shouldn't matter.

Rickard von Essen

unread,
Jun 14, 2017, 2:18:36 PM6/14/17
to packe...@googlegroups.com
> I don't understand why Packer is trying to use the Task Scheduler to run PowerShell scripts in the first place. Why doesn't it just upload the script and execute?

To my understanding that is how you must do it to elevate privileges and run a script. If you have another way of doing it please enlightening us. 

--
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 packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/9ebfe018-63ea-476a-968e-763b614b0020%40googlegroups.com.

Wil Taylor

unread,
Jun 14, 2017, 6:41:00 PM6/14/17
to packe...@googlegroups.com
I think the scheduled task is to work around an issue with Windows Update API. You can't run it via WinRM you have to run it locally on the system. Using the Task Scheduler works around this.

On Thu, Jun 15, 2017 at 4:18 AM Rickard von Essen <rickard....@gmail.com> wrote:
> I don't understand why Packer is trying to use the Task Scheduler to run PowerShell scripts in the first place. Why doesn't it just upload the script and execute?

To my understanding that is how you must do it to elevate privileges and run a script. If you have another way of doing it please enlightening us. 

On Jun 14, 2017 18:59, "Joshua H." <jth0...@gmail.com> wrote:
I too am getting the exact same error with Server 2012. I'm not sure exactly what the issue is, or how to work around it. This is with Packer 1.0.0.

I don't understand why Packer is trying to use the Task Scheduler to run PowerShell scripts in the first place. Why doesn't it just upload the script and execute?

The OP said not elevating the script seems to work, so I will give that a shot, but that shouldn't matter.

--
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 packer-tool...@googlegroups.com.
--
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 a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/QKlsgxYqUSY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages