"settings" contains an invalid JSON: invalid character ',' after object key

I’m receiving the error "settings contains and invalid character ‘,’ in the following block of code. The line is calling Powershell commands. The command works fine in PS but when I add this code to my TF script it generates this error. The only ‘,’ are the ones in the PS command which are required. How do I get past this error?

// IIS and .NET install
resource "azurerm_virtual_machine_extension" "vm_extension_install_iis_dotnet" {
  name                       = "vm_extension_install_iis_dotnet"
  virtual_machine_id         = azurerm_windows_virtual_machine.mc001.id
  publisher                  = "Microsoft.Compute"
  type                       = "CustomScriptExtension"
  type_handler_version       = "1.8"
  auto_upgrade_minor_version = true

  settings = <<SETTINGS
    {

"commandToExecute": "powershell -ExecutionPolicy Unrestricted Install-WindowsFeature -Name @(“Web-HTTP-Redirect", "Web-Request-Monitor", "Web-Windows-Auth", "Web-Includes", "Web-WebSockets", "Web-Metabase", "Web-Lgcy-Mgmt-Console", "Web-Scripting-Tools", "Web-Mgmt-Service")"
    }
SETTINGS
}

This may not be the only way to solve this issue (and is definitely not the neatest) but you will need to escape the quotes in the middle of the script by using a \ before each of them (except the outer quotes).

See Strings and Templates - Configuration Language - Terraform by HashiCorp

Thx for lead. I implemented the ‘’ as you suggested. I now get a similar error stating:

Error: “settings” contains an invalid JSON: invalid character ‘â’ in string escape code

│ with azurerm_virtual_machine_extension.vm_extension_install_iis_dotnet,
│ on main.tf line 97, in resource “azurerm_virtual_machine_extension” “vm_extension_install_iis_dotnet”:
│ 97: resource “azurerm_virtual_machine_extension” “vm_extension_install_iis_dotnet” {

There is no ‘â’ anywhere in the script. Is there any documentation regarding TF and the “commandtoexecute” command?

Thx for lead. I implemented the ‘’ as you suggested. I now get a similar error stating:

Error: “settings” contains an invalid JSON: invalid character ‘â’ in string escape code

│ with azurerm_virtual_machine_extension.vm_extension_install_iis_dotnet,
│ on main.tf line 97, in resource “azurerm_virtual_machine_extension” “vm_extension_install_iis_dotnet”:
│ 97: resource “azurerm_virtual_machine_extension” “vm_extension_install_iis_dotnet” {

There is no ‘â’ anywhere in the script. Is there any documentation regarding TF and the “commandtoexecute” command?