title: How do I pass a powershell script to a VM? Escaping \ doesn't seem to work
body: <p>I am trying to have my terraform script run a powershell script on a VM when it's provisioned.  I know it's trying to run but it's erroring out.  I believe it's because the backslash in the file paths.  I've tried escaping it, by making each single back slash into a double, but then it seems to be passed literally instead of as a simple single backslash, and that is failing too.</p>
  <p>So how do I do it?  anyone?  thank you much</p>
  <pre><code>resource &quot;azurerm_virtual_machine_extension&quot; &quot;dc&quot; {
    name                 = var.DomainControllerVMName
    virtual_machine_id   = azurerm_windows_virtual_machine.dc.id
    publisher            = &quot;Microsoft.Azure.Extensions&quot;
    type                 = &quot;CustomScript&quot;
    type_handler_version = &quot;2.0&quot;
  
    settings = jsonencode({
      commandToExecute = &quot;$password = convertto-securestring RkP83Ls4S8wV -asplaintext -force;Install-windowsfeature -name AD-Domain-Services –IncludeManagementTool;Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath C:\windows\NTDS -DomainMode WinThreshold -DomainName mdk.mydomain.com -DomainNetbiosName MDK -ForestMode WinThreshold -InstallDns:$true -SafeModeAdministratorPassword $password -LogPath C:\windows\NTDS -NoRebootOnCompletion:$false -SysvolPath C:\windows\SYSVOL -Force:$true -Confirm:$false&quot;
    })
  
  
    tags = {
      environment = &quot;Production&quot;
    }
  
    depends_on = [azurerm_windows_virtual_machine.dc]
  }
  </code></pre>