I’m trying to figure out the proper way to pass terraform variable value to my powershell script.
The script fails when i try to deploy it using Microsoft extension.
below my terraform script.
`resource "azurerm_virtual_machine_extension" "test" {
name = "testt"
virtual_machine_id = azurerm_virtual_machine.example.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
protected_settings = <<SETTINGS
{
"commandToExecute": "powershell -command "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(‘${base64encode(file("shell.ps1"))}’)) | Out-File -filepath shell.ps1" && powershell -ExecutionPolicy Unrestricted -File shell.ps1 -value1 ${var.value1} -value2 ${var.value2}"
}
SETTINGS
}`
Below powershell script
`param(
[string]$value1,
[string]$value2
)`
Error i am facing
"message": "param : The term ‘param’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check rnthe spelling of the name, or if a path was included, verify that the path is correct and try again.
2
Answers
Have you tried something like this?