{"record":{"id":"32e03a9ff7a8f9e3","repo":"hashicorp/packer","slug":"either-a-script-file-or-inline-script-must-be-spec","errorCode":null,"errorMessage":"Either a script file or inline script must be specified.","messagePattern":"Either a script file or inline script must be specified\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/powershell/provisioner.go","lineNumber":240,"sourceCode":"\n\tvar errs error\n\tif p.config.Script != \"\" && len(p.config.Scripts) > 0 {\n\t\terrs = packersdk.MultiErrorAppend(errs,\n\t\t\terrors.New(\"Only one of script or scripts can be specified.\"))\n\t}\n\n\tif p.config.ElevatedUser == \"\" && p.config.ElevatedPassword != \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs,\n\t\t\terrors.New(\"Must supply an 'elevated_user' if 'elevated_password' provided\"))\n\t}\n\n\tif p.config.Script != \"\" {\n\t\tp.config.Scripts = []string{p.config.Script}\n\t}\n\n\tif len(p.config.Scripts) == 0 && p.config.Inline == nil {\n\t\terrs = packersdk.MultiErrorAppend(errs,\n\t\t\terrors.New(\"Either a script file or inline script must be specified.\"))\n\t} else if len(p.config.Scripts) > 0 && p.config.Inline != nil {\n\t\terrs = packersdk.MultiErrorAppend(errs,\n\t\t\terrors.New(\"Only a script file or an inline script can be specified, not both.\"))\n\t}\n\n\tif p.config.ExecuteCommand == \"\" {\n\t\tif p.config.Inline != nil && len(p.config.Scripts) == 0 {\n\t\t\tp.config.ExecuteCommand = p.defaultExecuteCommand()\n\t\t\tlog.Printf(\"Using inline default execute command %s\", p.config.ExecuteCommand)\n\t\t} else {\n\t\t\tp.config.ExecuteCommand = p.defaultScriptCommand()\n\t\t\tlog.Printf(\"Using script default execute command %s\", p.config.ExecuteCommand)\n\t\t}\n\n\t}\n\n\tif p.config.ElevatedExecuteCommand == \"\" {\n\t\tif p.config.Inline != nil && len(p.config.Scripts) == 0 {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/powershell/provisioner.go#L222-L258","documentation":"After normalizing script into scripts, Prepare requires the provisioner to have something to execute: either at least one entry in scripts or an inline script array. If both are empty there is no work to do, so the template is rejected. This catches provisioner blocks that exist but configure no actual PowerShell payload.","triggerScenarios":"A powershell provisioner block with neither script(s) nor inline set; or script/scripts/inline all sourced from empty variables at build time (e.g. scripts = var.script_list where var.script_list is []).","commonSituations":"Scaffolding a provisioner block before writing the script; templating where the script variable is empty for a given build; commenting out the script line during debugging and forgetting to restore it.","solutions":["Set scripts = [\"path/to/script.ps1\"] (or script for a single file).","Or provide inline = [\"Write-Host 'hello'\"] for ad-hoc commands.","Verify variables feeding scripts/inline are non-empty for this build target."],"exampleFix":"// before\nprovisioner \"powershell\" {\n  elevated_user = \"Administrator\"\n}\n\n// after\nprovisioner \"powershell\" {\n  scripts       = [\"./setup.ps1\"]\n  elevated_user = \"Administrator\"\n}","handlingStrategy":"validation","validationCode":"// Ensure the block has a payload before building:\n// scripts.len > 0 || inline != null\nassert {\n  condition     = length(var.ps_scripts) > 0 || length(var.ps_inline) > 0\n  error_message = \"powershell provisioner needs script(s) or inline.\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave a provisioner block as an empty stub; scaffold it with at least one inline entry.","Verify variables feeding scripts/inline are populated for all target builds.","Run packer validate as part of CI."],"tags":["packer","provisioner","powershell","config-validation"],"backgroundTag":"missing-required-argument","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"}