"Provisioning with shell script" occasionally not working

829 views
Skip to first unread message

andr...@gmail.com

unread,
Oct 19, 2017, 9:21:38 PM10/19/17
to Packer
I know that this one is hard to track down, so I'm mainly writing so that the others new that there is a potential problem and on the off-chance that someone came across this one already.

In a Windows Server build I'm running quite a few shell (powershell) provisioner steps. Sometimes some of these steps fail without error. For example:

[00:38:53][Step 1/2] ==> windows-2012-base: Provisioning with Powershell...
[00:38:53][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/debloat-windows.ps1
[00:38:53][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-choco.ps1
[00:38:54][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-7z.ps1
[00:38:54][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-vmtools.ps1
[00:38:54][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-bginfo.ps1
[00:38:55][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-antivirus.ps1
[00:38:55][Step 1/2] ==> windows-2012-base: Restarting Machine
[00:38:55][Step 1/2] ==> windows-2012-base: Waiting for machine to restart...

As you can see there are no errors displayed here, yet the scripts are not executed. There is no result of their execution in the resulting image and there is no output these script display in the log. They don't have to fail all together some time just one fails and it could be a different one each time. This is what output looks like when these work:


[08:15:50][Step 1/2] ==> windows-2012-base: Provisioning with Powershell...
[08:15:50][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/debloat-windows.ps1
[08:17:04][Step 1/2]     windows-2012-base: #< CLIXML
[08:17:05][Step 1/2]     windows-2012-base: Downloading debloat zip
[08:17:13][Step 1/2]     windows-2012-base: Disable Windows Defender
[08:17:29][Step 1/2]     windows-2012-base:
[08:17:29][Step 1/2]     windows-2012-base: Success Restart Needed Exit Code      Feature Result
[08:17:29][Step 1/2]     windows-2012-base: ------- -------------- ---------      --------------
[08:17:29][Step 1/2]     windows-2012-base: False   No             InvalidArgs    {}
[08:17:29][Step 1/2]     windows-2012-base: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="information" RefId="1"><TN RefId="1"><T>System.Management.Automation.InformationRecord</T><T>System.Object</T></TN><ToString>Downloading debloat zip</ToString><Props><Obj N="MessageData" RefId="2"><TN RefId="2"><T>System.Management.Automation.HostInformationMessage</T><T>System.Object</T></TN><ToString>Downloading debloat zip</ToString><Props><S N="Message">Downloading debloat zip</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Windows\Temp\script.ps1</S><DT N="TimeGenerated">2017-10-07T08:17:04.2414592+13:00</DT><Obj N="Tags" RefId="3"><TN RefId="3"><T>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</T><T>System.Object</T></TN><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">1712</U32><U32 N="NativeThreadId">1868</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><Obj S="information" RefId="4"><TNRef RefId="1" /><ToString>Disable Windows Defender</ToString><Props><Obj N="MessageData" RefId="5"><TNRef RefId="2" /><ToString>Disable Windows Defender</ToString><Props><S N="Message">Disable Windows Defender</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Windows\Temp\script.ps1</S><DT N="TimeGenerated">2017-10-07T08:17:11.9285715+13:00</DT><Obj N="Tags" RefId="6"><TNRef RefId="3" /><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">1712</U32><U32 N="NativeThreadId">1868</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><S S="Error">Uninstall-WindowsFeature : ArgumentNotValid: The role, role service, or _x000D__x000A_</S><S S="Error">feature name is not valid: 'Windows-Defender-Features'. The name was not found._x000D__x000A_</S><S S="Error">At C:\Windows\Temp\script.ps1:17 char:3_x000D__x000A_</S><S S="Error">+   Uninstall-WindowsFeature Windows-Defender-Features_x000D__x000A_</S><S S="Error">+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : InvalidArgument: (Windows-Defender-Features:Stri _x000D__x000A_</S><S S="Error">   ng) [Uninstall-WindowsFeature], Exception_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : NameDoesNotExist,Microsoft.Windows.ServerManager _x000D__x000A_</S><S S="Error">   .Commands.RemoveWindowsFeatureCommand_x000D__x000A_</S></Objs>
[08:17:29][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-choco.ps1
[08:17:40][Step 1/2]     windows-2012-base: #< CLIXML
[08:17:42][Step 1/2]     windows-2012-base:
[08:17:42][Step 1/2]     windows-2012-base: Mode                LastWriteTime         Length Name
[08:17:42][Step 1/2]     windows-2012-base: ----                -------------         ------ ----
[08:17:42][Step 1/2]     windows-2012-base: d-----       7/10/2017  8:17 a.m.                chocInstall
[08:17:42][Step 1/2]     windows-2012-base: Getting latest version of the Chocolatey package for download.
[08:17:42][Step 1/2]     windows-2012-base: Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.8.
[08:17:45][Step 1/2]     windows-2012-base: Downloading 7-Zip commandline tool prior to extraction.
[08:17:45][Step 1/2]     windows-2012-base: Extracting C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall...
[08:17:45][Step 1/2]     windows-2012-base: Installing chocolatey on this machine
[08:17:45][Step 1/2]     windows-2012-base: Creating ChocolateyInstall as an environment variable (targeting 'Machine')
[08:17:45][Step 1/2]     windows-2012-base: Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
[08:17:45][Step 1/2]     windows-2012-base: WARNING: It's very likely you will need to close and reopen your shell
[08:17:45][Step 1/2]     windows-2012-base: before you can use choco.
[08:17:49][Step 1/2]     windows-2012-base: Restricting write permissions to Administrators
[08:17:49][Step 1/2]     windows-2012-base: We are setting up the Chocolatey package repository.
[08:17:49][Step 1/2]     windows-2012-base: The packages themselves go to 'C:\ProgramData\chocolatey\lib'
[08:17:49][Step 1/2]     windows-2012-base: (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
[08:17:49][Step 1/2]     windows-2012-base: A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
[08:17:49][Step 1/2]     windows-2012-base: and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
[08:17:49][Step 1/2]     windows-2012-base:
[08:17:49][Step 1/2]     windows-2012-base: Creating Chocolatey folders if they do not already exist.
[08:17:49][Step 1/2]     windows-2012-base:
[08:17:49][Step 1/2]     windows-2012-base: WARNING: You can safely ignore errors related to missing log files when
[08:17:49][Step 1/2]     windows-2012-base: upgrading from a version of Chocolatey less than 0.9.9.
[08:17:49][Step 1/2]     windows-2012-base: 'Batch file could not be found' is also safe to ignore.
[08:17:49][Step 1/2]     windows-2012-base: 'The system cannot find the file specified' - also safe.
[08:17:49][Step 1/2]     windows-2012-base: chocolatey.nupkg file not installed in lib.
[08:17:49][Step 1/2]     windows-2012-base: Attempting to locate it from bootstrapper.
[08:17:49][Step 1/2]     windows-2012-base: PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
[08:17:49][Step 1/2]     windows-2012-base: Chocolatey (choco.exe) is now ready.
[08:17:49][Step 1/2]     windows-2012-base: You can call choco from anywhere, command line or powershell by typing choco.
[08:17:49][Step 1/2]     windows-2012-base: Run choco /? for a list of functions.
[08:17:49][Step 1/2]     windows-2012-base: You may need to shut down and restart powershell and/or consoles
[08:17:49][Step 1/2]     windows-2012-base: first prior to using choco.
[08:17:49][Step 1/2]     windows-2012-base: Ensuring chocolatey commands are on the path
[08:17:49][Step 1/2]     windows-2012-base: Ensuring chocolatey.nupkg is in the lib folder
[08:17:49][Step 1/2]     windows-2012-base: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="information" RefId="1"><TN RefId="1"><T>System.Management.Automation.InformationRecord</T><T>System.Object</T></TN><ToString>WARNING: It's very likely you will need to close and reopen your shell _x000A_  before you can use choco.</ToString><Props><Obj N="MessageData" RefId="2"><TN RefId="2"><T>System.Management.Automation.HostInformationMessage</T><T>System.Object</T></TN><ToString>WARNING: It's very likely you will need to close and reopen your shell _x000A_  before you can use choco.</ToString><Props><S N="Message">WARNING: It's very likely you will need to close and reopen your shell _x000A_  before you can use choco.</S><B N="NoNewLine">false</B><S N="ForegroundColor">Yellow</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1</S><DT N="TimeGenerated">2017-10-07T08:17:44.6474789+13:00</DT><Obj N="Tags" RefId="3"><TN RefId="3"><T>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</T><T>System.Object</T></TN><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">2912</U32><U32 N="NativeThreadId">2952</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><Obj S="information" RefId="4"><TNRef RefId="1" /><ToString>WARNING: You can safely ignore errors related to missing log files when _x000A_  upgrading from a version of Chocolatey less than 0.9.9. _x000A_  'Batch file could not be found' is also safe to ignore. _x000A_  'The system cannot find the file specified' - also safe.</ToString><Props><Obj N="MessageData" RefId="5"><TNRef RefId="2" /><ToString>WARNING: You can safely ignore errors related to missing log files when _x000A_  upgrading from a version of Chocolatey less than 0.9.9. _x000A_  'Batch file could not be found' is also safe to ignore. _x000A_  'The system cannot find the file specified' - also safe.</ToString><Props><S N="Message">WARNING: You can safely ignore errors related to missing log files when _x000A_  upgrading from a version of Chocolatey less than 0.9.9. _x000A_  'Batch file could not be found' is also safe to ignore. _x000A_  'The system cannot find the file specified' - also safe.</S><B N="NoNewLine">false</B><S N="ForegroundColor">Yellow</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateysetup.psm1</S><DT N="TimeGenerated">2017-10-07T08:17:47.663384+13:00</DT><Obj N="Tags" RefId="6"><TNRef RefId="3" /><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">2912</U32><U32 N="NativeThreadId">2952</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><Obj S="information" RefId="7"><TNRef RefId="1" /><ToString>PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...</ToString><Props><Obj N="MessageData" RefId="8"><TNRef RefId="2" /><ToString>PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...</ToString><Props><S N="Message">PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateyInstall\helpers\functions\Install-ChocolateyPath.ps1</S><DT N="TimeGenerated">2017-10-07T08:17:48.1164687+13:00</DT><Obj N="Tags" RefId="9"><TNRef RefId="3" /><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">2912</U32><U32 N="NativeThreadId">2952</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><S S="warning">Not setting tab completion: Profile file does not exist at 'C:\Users\vagrant\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.</S></Objs>
[08:17:49][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-7z.ps1
[08:18:00][Step 1/2]     windows-2012-base: #< CLIXML
[08:18:02][Step 1/2]     windows-2012-base: Chocolatey v0.10.8
[08:18:02][Step 1/2]     windows-2012-base: Installing the following packages:
[08:18:02][Step 1/2]     windows-2012-base: 7zip
[08:18:02][Step 1/2]     windows-2012-base: By installing you accept licenses for the packages.
[08:18:08][Step 1/2]     windows-2012-base: Progress: Downloading 7zip.install 16.4.0.20170506... 100%
[08:18:11][Step 1/2]     windows-2012-base: Progress: Downloading chocolatey-core.extension 1.3.1... 100%
[08:18:13][Step 1/2]     windows-2012-base: Progress: Downloading 7zip 16.4.0.20170506... 100%
[08:18:13][Step 1/2]     windows-2012-base:
[08:18:13][Step 1/2]     windows-2012-base: chocolatey-core.extension v1.3.1 [Approved]
[08:18:13][Step 1/2]     windows-2012-base: chocolatey-core.extension package files install completed. Performing other installation steps.
[08:18:15][Step 1/2]     windows-2012-base: Installed/updated chocolatey-core extensions.
[08:18:15][Step 1/2]     windows-2012-base: The install of chocolatey-core.extension was successful.
[08:18:15][Step 1/2]     windows-2012-base: Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'
[08:18:15][Step 1/2]     windows-2012-base:
[08:18:15][Step 1/2]     windows-2012-base: 7zip.install v16.4.0.20170506 [Approved]
[08:18:15][Step 1/2]     windows-2012-base: 7zip.install package files install completed. Performing other installation steps.
[08:18:20][Step 1/2]     windows-2012-base: Installing 64 bit version
[08:18:20][Step 1/2]     windows-2012-base: Installing 7zip.install...
[08:18:22][Step 1/2]     windows-2012-base: 7zip.install has been installed.
[08:18:22][Step 1/2]     windows-2012-base: 7zip installed to 'C:\Program Files\7-Zip'
[08:18:23][Step 1/2]     windows-2012-base: Added C:\ProgramData\chocolatey\bin\7z.exe shim pointed to 'c:\program files\7-zip\7z.exe'.
[08:18:23][Step 1/2]     windows-2012-base: 7zip.install may be able to be automatically uninstalled.
[08:18:23][Step 1/2]     windows-2012-base: The install of 7zip.install was successful.
[08:18:23][Step 1/2]     windows-2012-base: Software installed to 'C:\Program Files\7-Zip\'
[08:18:23][Step 1/2]     windows-2012-base:
[08:18:23][Step 1/2]     windows-2012-base: 7zip v16.4.0.20170506 [Approved]
[08:18:23][Step 1/2]     windows-2012-base: 7zip package files install completed. Performing other installation steps.
[08:18:23][Step 1/2]     windows-2012-base: The install of 7zip was successful.
[08:18:23][Step 1/2]     windows-2012-base: Software install location not explicitly set, could be in package or
[08:18:23][Step 1/2]     windows-2012-base: default install location if installer.
[08:18:23][Step 1/2]     windows-2012-base:
[08:18:23][Step 1/2]     windows-2012-base: Chocolatey installed 3/3 packages.
[08:18:23][Step 1/2]     windows-2012-base: See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
[08:18:23][Step 1/2]     windows-2012-base: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
[08:18:23][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-vmtools.ps1
[08:18:35][Step 1/2]     windows-2012-base:
[08:18:35][Step 1/2]     windows-2012-base: #< CLIXML
[08:18:35][Step 1/2]     windows-2012-base:
[08:18:35][Step 1/2]     windows-2012-base: Directory: C:\Windows\Temp
[08:18:35][Step 1/2]     windows-2012-base:
[08:18:35][Step 1/2]     windows-2012-base:
[08:18:35][Step 1/2]     windows-2012-base: Mode                LastWriteTime         Length Name
[08:18:35][Step 1/2]     windows-2012-base: ----                -------------         ------ ----
[08:18:35][Step 1/2]     windows-2012-base: d-----       7/10/2017  8:18 a.m.                VmWare
[08:18:35][Step 1/2]     windows-2012-base: Downloading tools
[08:18:43][Step 1/2]     windows-2012-base: Extracting tools
[08:18:43][Step 1/2]     windows-2012-base:
[08:18:43][Step 1/2]     windows-2012-base: 7-Zip [64] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04
[08:18:43][Step 1/2]     windows-2012-base:
[08:18:43][Step 1/2]     windows-2012-base: Scanning the drive for archives:
[08:18:43][Step 1/2]     windows-2012-base: 1 file, 82018304 bytes (79 MiB)
[08:18:43][Step 1/2]     windows-2012-base:
[08:18:43][Step 1/2]     windows-2012-base: Extracting archive: C:\Windows\Temp\windows.iso
[08:18:43][Step 1/2]     windows-2012-base: --
[08:18:43][Step 1/2]     windows-2012-base: Path = C:\Windows\Temp\windows.iso
[08:18:43][Step 1/2]     windows-2012-base: Type = Iso
[08:18:43][Step 1/2]     windows-2012-base: Physical Size = 82018304
[08:18:43][Step 1/2]     windows-2012-base: Created = 2017-07-19 22:54:25
[08:18:43][Step 1/2]     windows-2012-base: Modified = 2017-07-19 22:54:25
[08:18:43][Step 1/2]     windows-2012-base:
[08:18:43][Step 1/2]     windows-2012-base: Everything is Ok
[08:18:43][Step 1/2]     windows-2012-base:
[08:18:43][Step 1/2]     windows-2012-base: Folders: 12
[08:18:43][Step 1/2]     windows-2012-base: Files: 24
[08:18:43][Step 1/2]     windows-2012-base: Size:       81835422
[08:18:43][Step 1/2]     windows-2012-base: Compressed: 82018304
[08:18:43][Step 1/2]     windows-2012-base: Running setup
[08:20:07][Step 1/2]     windows-2012-base: Exit code: 3010
[08:20:07][Step 1/2]     windows-2012-base: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="information" RefId="1"><TN RefId="1"><T>System.Management.Automation.InformationRecord</T><T>System.Object</T></TN><ToString>Downloading tools</ToString><Props><Obj N="MessageData" RefId="2"><TN RefId="2"><T>System.Management.Automation.HostInformationMessage</T><T>System.Object</T></TN><ToString>Downloading tools</ToString><Props><S N="Message">Downloading tools</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Windows\Temp\script.ps1</S><DT N="TimeGenerated">2017-10-07T08:18:34.0850342+13:00</DT><Obj N="Tags" RefId="3"><TN RefId="3"><T>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</T><T>System.Object</T></TN><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">864</U32><U32 N="NativeThreadId">1276</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><Obj S="information" RefId="4"><TNRef RefId="1" /><ToString>Extracting tools</ToString><Props><Obj N="MessageData" RefId="5"><TNRef RefId="2" /><ToString>Extracting tools</ToString><Props><S N="Message">Extracting tools</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Windows\Temp\script.ps1</S><DT N="TimeGenerated">2017-10-07T08:18:41.5068677+13:00</DT><Obj N="Tags" RefId="6"><TNRef RefId="3" /><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">864</U32><U32 N="NativeThreadId">1276</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><Obj S="information" RefId="7"><TNRef RefId="1" /><ToString>Running setup</ToString><Props><Obj N="MessageData" RefId="8"><TNRef RefId="2" /><ToString>Running setup</ToString><Props><S N="Message">Running setup</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Windows\Temp\script.ps1</S><DT N="TimeGenerated">2017-10-07T08:18:41.741493+13:00</DT><Obj N="Tags" RefId="9"><TNRef RefId="3" /><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">864</U32><U32 N="NativeThreadId">1276</U32><U32 N="ManagedThreadId">7</U32></Props></Obj><Obj S="information" RefId="10"><TNRef RefId="1" /><ToString>Exit code: 3010</ToString><Props><Obj N="MessageData" RefId="11"><TNRef RefId="2" /><ToString>Exit code: 3010</ToString><Props><S N="Message">Exit code: 3010</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\Windows\Temp\script.ps1</S><DT N="TimeGenerated">2017-10-07T08:20:11.9943107+13:00</DT><Obj N="Tags" RefId="12"><TNRef RefId="3" /><LST><S>PSHOST</S></LST></Obj><S N="User">VAGRANT-2012\vagrant</S><S N="Computer">vagrant-2012</S><U32 N="ProcessId">864</U32><U32 N="NativeThreadId">1276</U32><U32 N="ManagedThreadId">7</U32></Props></Obj></Objs>
[08:20:07][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-bginfo.ps1
[08:20:19][Step 1/2]     windows-2012-base:
[08:20:19][Step 1/2]     windows-2012-base: #< CLIXML
[08:20:19][Step 1/2]     windows-2012-base:
[08:20:19][Step 1/2]     windows-2012-base: Directory: C:\Program Files
[08:20:19][Step 1/2]     windows-2012-base:
[08:20:19][Step 1/2]     windows-2012-base:
[08:20:19][Step 1/2]     windows-2012-base: Mode                LastWriteTime         Length Name
[08:20:19][Step 1/2]     windows-2012-base: ----                -------------         ------ ----
[08:20:19][Step 1/2]     windows-2012-base: d-----       7/10/2017  8:20 a.m.                BGInfo
[08:20:23][Step 1/2]     windows-2012-base: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
[08:20:23][Step 1/2] ==> windows-2012-base: Provisioning with shell script: ./scripts/install-antivirus.ps1
[08:20:35][Step 1/2]     windows-2012-base: #< CLIXML
[08:23:35][Step 1/2]     windows-2012-base: <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>
[08:23:35][Step 1/2] ==> windows-2012-base: Restarting Machine
[08:23:49][Step 1/2] ==> windows-2012-base: Waiting for machine to restart...

This is what the relevant part of packer config looks like:

    {
      "type": "windows-restart"
    },
    {
      "type": "powershell",
      "valid_exit_codes": [ 0, 3010 ],
      "scripts": [
        "./scripts/debloat-windows.ps1",
        "./scripts/install-choco.ps1",
        "./scripts/install-7z.ps1",
        "./scripts/install-vmtools.ps1", 
        "./scripts/install-bginfo.ps1",
"./scripts/install-antivirus.ps1"
      ]
    },
    {
      "type": "windows-restart"
    },


This is, for example, the contents of install-choco.ps1:

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

This is an excerpt from packer log when this problem is occurring:

2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Connected to machine
2017/10/14 00:38:59 ui: ==> windows-2012-base: Machine successfully restarted, moving on
2017/10/14 00:38:59 [INFO] (telemetry) ending windows-restart
2017/10/14 00:38:59 [INFO] (telemetry) Starting provisioner powershell
2017/10/14 00:38:59 ui: ==> windows-2012-base: Provisioning with Powershell...
2017/10/14 00:38:59 ui: ==> windows-2012-base: Provisioning with shell script: ./scripts/debloat-windows.ps1
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Opening ./scripts/debloat-windows.ps1 for reading
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Building command line for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="windows-2012-base"; &'c:/Windows/Temp/script.ps1';exit $LastExitCode
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] 1308 bytes written for 'uploadData'
2017/10/14 00:38:59 [INFO] 1308 bytes written for 'uploadData'
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Uploading file to 'c:/Windows/Temp/script.ps1'
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] starting remote command: powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] command 'powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==' exited with code: 0
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:38:59 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:38:59 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:38:59 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:38:59 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:38:59 ui: ==> windows-2012-base: Provisioning with shell script: ./scripts/install-choco.ps1
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Opening ./scripts/install-choco.ps1 for reading
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Building command line for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="windows-2012-base"; &'c:/Windows/Temp/script.ps1';exit $LastExitCode
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 [INFO] 94 bytes written for 'uploadData'
2017/10/14 00:38:59 [INFO] 94 bytes written for 'uploadData'
2017/10/14 00:38:59 packer.exe: 2017/10/14 00:38:59 Uploading file to 'c:/Windows/Temp/script.ps1'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] starting remote command: powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] command 'powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==' exited with code: 0
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:00 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:00 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:00 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:00 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:00 ui: ==> windows-2012-base: Provisioning with shell script: ./scripts/install-7z.ps1
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Opening ./scripts/install-7z.ps1 for reading
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Building command line for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="windows-2012-base"; &'c:/Windows/Temp/script.ps1';exit $LastExitCode
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 15 bytes written for 'uploadData'
2017/10/14 00:39:00 [INFO] 15 bytes written for 'uploadData'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Uploading file to 'c:/Windows/Temp/script.ps1'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] starting remote command: powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] command 'powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==' exited with code: 0
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:00 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:00 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:00 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:00 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:00 ui: ==> windows-2012-base: Provisioning with shell script: ./scripts/install-vmtools.ps1
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Opening ./scripts/install-vmtools.ps1 for reading
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Building command line for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="windows-2012-base"; &'c:/Windows/Temp/script.ps1';exit $LastExitCode
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 765 bytes written for 'uploadData'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Uploading file to 'c:/Windows/Temp/script.ps1'
2017/10/14 00:39:00 [INFO] 765 bytes written for 'uploadData'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] starting remote command: powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] command 'powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==' exited with code: 0
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:00 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:00 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:00 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:00 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:00 ui: ==> windows-2012-base: Provisioning with shell script: ./scripts/install-bginfo.ps1
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Opening ./scripts/install-bginfo.ps1 for reading
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Building command line for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="windows-2012-base"; &'c:/Windows/Temp/script.ps1';exit $LastExitCode
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 [INFO] 654 bytes written for 'uploadData'
2017/10/14 00:39:00 [INFO] 654 bytes written for 'uploadData'
2017/10/14 00:39:00 packer.exe: 2017/10/14 00:39:00 Uploading file to 'c:/Windows/Temp/script.ps1'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] starting remote command: powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] command 'powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==' exited with code: 0
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:01 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:01 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:01 ui: ==> windows-2012-base: Provisioning with shell script: ./scripts/install-antivirus.ps1
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 Opening ./scripts/install-antivirus.ps1 for reading
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 Building command line for: if (Test-Path variable:global:ProgressPreference){$ProgressPreference='SilentlyContinue'};$env:PACKER_BUILDER_TYPE="vmware-iso"; $env:PACKER_BUILD_NAME="windows-2012-base"; &'c:/Windows/Temp/script.ps1';exit $LastExitCode
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 219 bytes written for 'uploadData'
2017/10/14 00:39:01 [INFO] 219 bytes written for 'uploadData'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 Uploading file to 'c:/Windows/Temp/script.ps1'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] starting remote command: powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] command 'powershell -executionpolicy bypass -encodedCommand aQBmACAAKABUAGUAcwB0AC0AUABhAHQAaAAgAHYAYQByAGkAYQBiAGwAZQA6AGcAbABvAGIAYQBsADoAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAKQB7ACQAUAByAG8AZwByAGUAcwBzAFAAcgBlAGYAZQByAGUAbgBjAGUAPQAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwB9ADsAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAEUAUgBfAFQAWQBQAEUAPQAiAHYAbQB3AGEAcgBlAC0AaQBzAG8AIgA7ACAAJABlAG4AdgA6AFAAQQBDAEsARQBSAF8AQgBVAEkATABEAF8ATgBBAE0ARQA9ACIAdwBpAG4AZABvAHcAcwAtADIAMAAxADIALQBiAGEAcwBlACIAOwAgACYAJwBjADoALwBXAGkAbgBkAG8AdwBzAC8AVABlAG0AcAAvAHMAYwByAGkAcAB0AC4AcABzADEAJwA7AGUAeABpAHQAIAAkAEwAYQBzAHQARQB4AGkAdABDAG8AZABlAA==' exited with code: 0
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:01 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:01 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] (telemetry) ending powershell
2017/10/14 00:39:01 [INFO] (telemetry) Starting provisioner windows-restart
2017/10/14 00:39:01 ui: ==> windows-2012-base: Restarting Machine
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] starting remote command: shutdown /r /f /t 0 /c "packer restart"
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] command 'shutdown /r /f /t 0 /c "packer restart"' exited with code: 0
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:01 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:01 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:01 [INFO] RPC endpoint: Communicator ended with: 0
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 0 bytes written for 'stderr'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] 0 bytes written for 'stdout'
2017/10/14 00:39:01 packer.exe: 2017/10/14 00:39:01 [INFO] RPC client: Communicator ended with: 0
2017/10/14 00:39:01 ui: ==> windows-2012-base: Waiting for machine to restart...



This is the rare case, when all of the scripts has failed. I've seen it once only. Most often just a single script fails here or there.


Andrew

Megan Marsh

unread,
Oct 20, 2017, 4:08:20 PM10/20/17
to packe...@googlegroups.com
Hey Andrew,

Can you open an issue on github?  I've put a lot of work into trying to make windows powershell more reliable lately and would like to take a look.

--
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/f3b06926-28f6-4b1e-809f-6f924867ff95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andr...@gmail.com

unread,
Oct 23, 2017, 5:51:12 PM10/23/17
to Packer

Megan Marsh

unread,
Oct 24, 2017, 1:14:53 PM10/24/17
to packe...@googlegroups.com
thanks!

--
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.
Reply all
Reply to author
Forward
0 new messages