I also tried to add the below script as a seperate powershell script to run
after the windoes-restart. But the Instance gets terminated before this
script finishes.
{
"type": "windows-restart",
"restart_check_command": "powershell -command \"& {Get-Process |
Where-Object { $_.Name -ne 'msiexec'};}\"",
"restart_timeout": "30m"
},
{
"script": "./scripts/restart_check.ps1",
"type": "powershell"
}
"restart_Checks.ps1"
----------------------------------
#############First check if msiexec is running, if not wait until it
starts.#############
while ($true)
{
if ((Get-Process -Name msiexec -ErrorAction SilentlyContinue) -eq $null)
{
Write-Host -ForegroundColor Red "MSI Process Is Not Running"
}
else
{
write-host -ForegroundColor Green "MSI Process Is Running"
break;
}
Start-Sleep -Seconds 10
}
#########Once msiexc is started running, wait until it gets
finished.#############
while ($true)
{
$isInstallerRunning=""
Write-Host "$(Get-Date)Checking for post installation completion..."
$isInstallerRunning = Get-Process | Where-Object { $_.Name -like
"msiexec" }
Write-Host "installreRunning Result = $isInstallerRunning"
if (-not ([string]::IsNullOrEmpty($isInstallerRunning)))
{
Write-Host "$(Get-Date) Restart is still in progress with post
installation steps ..."
Start-Sleep -Seconds 10
}
else
{
Write-Host "$(Get-Date) msiexec is not running anymore"
break;
}
}
On Thu, Dec 6, 2018 at 10:52 AM Subha <[email protected]> wrote:
> Hi Alvaro,
>
> Thank you, Which Script are you referring to? I dont see any script in the
> documentation.
> https://www.packer.io/docs/provisioners/windows-restart.html#restart_check_command
>
> It just uses a powershell command.
> Can you please give me more specific. Thank you and sorry if its to much
> to ask. I am a newbie here.
>
> Thanks for your help
>
>
>
> On Thu, Dec 6, 2018 at 4:34 AM Alvaro Miranda Aguilera <[email protected]>
> wrote:
>
>> well
>>
>> packer need that to confirm machine is up and running again
>>
>> a script like the example in the documentation is you need for the
>> restart part
>>
>> --
>> 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/CAHqq0eyHx7umvcHtKFN4sp6RZ27x6L04bBhwFFqyhbE7cW9p1w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/packer-tool/CAHqq0eyHx7umvcHtKFN4sp6RZ27x6L04bBhwFFqyhbE7cW9p1w%40mail.gmail.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/CAEDMBCz7CiwzaOLC3H1-eQveR%2Bx30oNTjuTU4ZfVb5nq%3DjR1Ng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.