Error while using virtual machine extension for windows operating system

Hi All,

Terraform Version: v1.6.6 AMD64
AzureRM version:3.64.0

I am creating multiple virtual machine using for each loop and I want to execute powershell script in all this virtual machine using “azurerm_virtual_machine_extension”.

Below is the code snippet
resource “azurerm_virtual_machine_extension” “install_new_vm” {
count = length(var.virtual_machine_name)
name = “${var.virtual_machine_name[count.index]}-vm”
virtual_machine_id =[count.index].id
publisher = “Microsoft.Compute”
type = “CustomScriptExtension”
type_handler_version = “1.10”

protected_settings = <<SETTINGS
“commandToExecute”: “powershell -command "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('{base64encode(data.template_file.dotnet_and_powerbi_script[count.index].rendered)}')) | Out-File -filepath dotnet_and_powerbi_script.ps1\" && powershell -ExecutionPolicy Unrestricted -File dotnet_and_powerbi_script.ps1 -GatewayName {} -GatewayKey ${[count.index].value}”
tags = local.all_tags
depends_on = [ ]

While executing above code I am getting error given below:
Error: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 – Original Error: Code=“BadRequest” Message=“Multiple VMExtensions per handler not supported for OS type ‘Windows’. VMExtension ‘new-vm’ with handler ‘Microsoft.Compute.CustomScriptExtension’ already added or specified in input.”

│ with azurerm_virtual_machine_extension.install_new_vm[1],
│ on line 76, in resource “azurerm_virtual_machine_extension” “install_new_vm”:
│ 76: resource “azurerm_virtual_machine_extension” “install_new_vm” {