PowerShell provisioner does not respond (elevated) Windows 10 #10989
Open
Description
Overview of the Issue
The PowerShell provisioner does not respond while running with extended rights (elevated) in Windows 10. It works for server images.
Reproduction Steps
- Create a packer configuration that creates a virtual machine in Azure.
- Use following image configuration:
image_publisher
:MicrosoftWindowsDesktop
image_offer
:Windows-10
image_sku
:19h2-ent-g2
- Add an elevated powershell provisioner:
...
{
"type": "powershell",
"inline": [
"net user {{user `install_user`}} {{user `install_password`}} /add /passwordchg:no /passwordreq:yes /active:yes /Y",
"net localgroup Administrators {{user `install_user`}} /add"
]
},
{
"type": "powershell",
"inline": [
"Write-Host Foo"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
}
...
- Execute the packer build.
Packer version
1.6.6
1.7.2
Simplified Packer Buildfile
{
"variables": {
"client_id": "{{env `ARM_CLIENT_ID`}}",
"client_secret": "{{env `ARM_CLIENT_SECRET`}}",
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
"tenant_id": "{{env `ARM_TENANT_ID`}}",
"object_id": "{{env `ARM_OBJECT_ID`}}",
"install_user": "installer",
"install_password": "{{env `INSTALL_PASSWORD`}}",
},
"builders": [
{
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"subscription_id": "{{user `subscription_id`}}",
"object_id": "{{user `object_id`}}",
"tenant_id": "{{user `tenant_id`}}",
"location": "westeurope",
"vm_size": "Standard_B4ms",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsDesktop",
"image_offer": "Windows-10",
"image_sku": "19h2-ent-g2",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_username": "packer"
}
],
"provisioners": [
{
"type": "powershell",
"inline": [
"net user {{user `install_user`}} {{user `install_password`}} /add /passwordchg:no /passwordreq:yes /active:yes /Y",
"net localgroup Administrators {{user `install_user`}} /add"
]
},
{
"type": "powershell",
"inline": [
"Write-Host Foo"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
}
]
}
Operating system and Environment details
-
Log Fragments and crash.log files
-
Relates to #7729, https://groups.google.com/g/packer-tool/c/6ToKPlCpsxM. Please notice - if I use the described workaround or log into the virtual machine, packer starts the script.