title: How to execute PowerShell command through Terraform
body: <p>I am trying to create a Windows Ec2 instance from AMI and executing a powershell command on that as :</p>
  
  <pre><code>data "aws_ami" "ec2-worker-initial-encrypted-ami" {
      filter {
          name   = "tag:Name"
          values = ["ec2-worker-initial-encrypted-ami"]
      }  
  }
  
  resource "aws_instance" "my-test-instance" {
    ami             = "${data.aws_ami.ec2-worker-initial-encrypted-ami.id}"
    instance_type   = "t2.micro"
  
    tags {
      Name = "my-test-instance"
    }
  
    provisioner "local-exec" {
      command = "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
      interpreter = ["PowerShell"]
    }
  
  }
  </code></pre>
  
  <p>and I am facing following error :</p>
  
  <blockquote>
    <ul>
    <li>aws_instance.my-test-instance: Error running command 'C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1
    -Schedule': exit status 1. Output: The term 'C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1'
    is not recognized as the name of a cmdlet, function, script file, or
    operable program. Check the spelling of the name, or if a path was
    included, verify that the path is correct and try again. At line:1
    char:72</li>
    <li>C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1
    &lt;&lt;&lt;&lt;  -Schedule
    
    <ul>
    <li>CategoryInfo          : ObjectNotFound: (C:\ProgramData...izeInstance.ps1:String) [],
    CommandNotFoundException</li>
    <li>FullyQualifiedErrorId : CommandNotFoundException</li>
    </ul></li>
    </ul>
  </blockquote>