{"record":{"id":"e4862ccf7685ec91","repo":"hashicorp/packer","slug":"error-generating-elevated-runner-s","errorCode":null,"errorMessage":"Error generating elevated runner: %s","messagePattern":"Error generating elevated runner: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/powershell/provisioner.go","lineNumber":634,"sourceCode":"\t// Prepare everything needed to enable the required env vars within the\n\t// remote environment\n\terr = p.prepareEnvVars(true)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tctxData := p.generatedData\n\tctxData[\"Path\"] = p.config.RemotePath\n\tctxData[\"Vars\"] = p.config.RemoteEnvVarPath\n\tp.config.ctx.Data = ctxData\n\n\tcommand, err = interpolate.Render(p.config.ElevatedExecuteCommand, &p.config.ctx)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error processing command: %s\", err)\n\t}\n\n\tcommand, err = guestexec.GenerateElevatedRunner(command, p)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Error generating elevated runner: %s\", err)\n\t}\n\n\treturn command, err\n}\n\nfunc (p *Provisioner) Communicator() packersdk.Communicator {\n\treturn p.communicator\n}\n\nfunc (p *Provisioner) ElevatedUser() string {\n\treturn p.config.ElevatedUser\n}\n\nfunc (p *Provisioner) ElevatedPassword() string {\n\t// Replace ElevatedPassword for winrm users who used this feature\n\tp.config.ctx.Data = p.generatedData\n\televatedPassword, _ := interpolate.Render(p.config.ElevatedPassword, &p.config.ctx)\n","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/powershell/provisioner.go#L616-L652","documentation":"After successfully rendering the elevated command, createCommandTextPrivileged calls guestexec.GenerateElevatedRunner, which builds the PowerShell wrapper that runs the command as an elevated user (via a scheduled task on Windows). If that generation fails, the error wraps the cause and provisioning aborts. Generation depends on the provisioner implementing the guestexec task-name/password interfaces.","triggerScenarios":"GenerateElevatedRunner fails: it cannot build the elevated runner template, the elevated_user/elevated_password context is incomplete (e.g. elevated_password unset while elevated_user is set), or the provisioner fails to satisfy the required interface methods.","commonSituations":"Setting elevated_user without elevated_password (or vice versa) in the template; Windows guests where scheduled-task creation prerequisites are missing; older Packer versions with different generated-data keys after upgrading templates.","solutions":["Read the wrapped cause; it names the specific generation step that failed.","If using elevated execution, ensure both elevated_user and elevated_password are correctly set (or rely on the auto-generated service account).","Verify the guest OS is Windows and supports the scheduled-task-based elevation mechanism.","Update the template to current Packer syntax; generated-data handling changed across versions."],"exampleFix":"// before\n\"elevated_user\": \"Administrator\"\n// after (provide the paired password)\n\"elevated_user\": \"Administrator\",\n\"elevated_password\": \"{{.WinRMPassword}}\"","handlingStrategy":"validation","validationCode":"// ensure elevated execution config is complete\n// HCL2:\n// elevated_user = \"Administrator\"\n// elevated_password = \"{{.WinRMPassword}}\"  # must be set when elevated_user is","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair elevated_user with elevated_password or omit both.","Confirm the guest is Windows and supports scheduled-task elevation.","Read the wrapped cause for the failing generation step.","Keep templates aligned with the Packer version's documented elevated variables."],"tags":["powershell","elevated","windows","provisioner"],"backgroundTag":"elevated-runner-generation-failed","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}