ScriptA.ps1 calls ScriptB.ps1 and it is failing in powershell provisioner with this error:
Both ScriptA.ps1 and ScriptB.ps1 are just one liner code to write out some message.

ScriptA.ps1 calls ScriptB.ps1 and it is failing in powershell provisioner with this error:
Both ScriptA.ps1 and ScriptB.ps1 are just one liner code to write out some message.

I have the exact same issue. Anyone found a solution?
Yes, the Powershell provisioner in tools like Packer or Terraform does support calling another PowerShell script. You can use the Invoke-Expression cmdlet or simply call the script using its path from within the provisioner.
Here’s an example of how you can do this:
json
“provisioners”: [
{
“type”: “powershell”,
“script”: “C:/path/to/your/script.ps1”
}
]
Alternatively, if you’re within a script and want to call another PowerShell script, you can do so like this:
powershell
& “C:\path\to\anotherScript.ps1”
This approach works well for chaining multiple scripts or calling a common script from within a larger provisioning process. Just ensure that the script path is correct, and that any necessary execution policies are set to allow script execution.