Powershell scripts get interrupted

18 views
Skip to first unread message

Lucas van Braam van Vloten

unread,
Jan 10, 2019, 12:04:22 PM1/10/19
to Packer
Hi,

I am using Packer to build an AWS AMI.
As part of the build process I am using the 'powershell' provisioner to run various PowerShell scripts.

Some of these scripts install software on the image, such as .NET Framework. The installer for .NET needs several minutes to do its work.

However, I see that the script is interrupted during the packer run. Somehow the script simply stops, I do not see any error messages, but any logging from the script simply stops. I do not see the logging that the second half of the script generates. The provisioner simply continues with the next reboot.

I am using the following configuration:


"provisioners": [
{
"type": "powershell",
"scripts": [
"./ec2/script1.ps1",
"./ec2/script2.ps1",
"./ec2/script3.ps1"
]
},
{
"type": "windows-restart"
},
{
"type": "powershell",
"scripts": [
"./ec2/netframework.ps1"
]
},
{
"type": "windows-restart"
},
{
"type": "powershell",
"pause_before": "30s",
"scripts": [
"./ec2/script5.ps1",
"./ec2/script6.ps1"
]
}
]

This is my command for installing .NET framework:
Start-Process -FilePath $installer -ArgumentList "/passive /norestart /log $Path/$filename.log" -Wait


The installation command seems to be correct.
Moreover, if I allow the script to enter a loop (like this: while ($true) {Start-Sleep 1; $i++; $i}), the reboot still follows after 15-60 seconds.

I am very confused. I would expect the script to complete normally, and the reboot to follow only after the script is finished.Does anyone have any suggestions what may be going on?

Kind regards,
Lucas

Reply all
Reply to author
Forward
0 new messages