title: PowerShell script with parameter for Windows VM instance on Google Cloud Platform
body: <p>I am trying to deploy Windows VM on Google Cloud through terraform. The VM is getting deployed and I am able to execute PowerShell scripts by using windows-startup-script-url.</p>
  
  <p>With this approach, I can only use scripts which are already stored in Google Storage. If the script has parameters / variables, then how to pass that parameter, any clue !</p>
  
  <pre><code>provider "google" {
    project = "my-project"
    region  = "my-location"
    zone    = "my-zone"
  }
  
  resource "google_compute_instance" "default" {
    name         = "my-name"
    machine_type = "n1-standard-2"
    zone         = "my-zone"
  
    boot_disk {
      initialize_params {
        image = "windows-cloud/windows-2019"
      }
    }
  
    metadata {
      windows-startup-script-url = "gs://&lt;my-storage&gt;/&lt;my-script.ps1&gt;"
    }
  
  
    network_interface {
      network = "default"
  
      access_config {
  
      }
    }
  
    tags = ["http-server", "windows-server"]
  }
  
  
  resource "google_compute_firewall" "http-server" {
    name    = "default-allow-http"
    network = "default"
  
    allow {
      protocol = "tcp"
      ports    = ["80"]
    }
  
  
    source_ranges = ["0.0.0.0/0"]
    target_tags   = ["http-server"]
  }
  
  resource "google_compute_firewall" "windows-server" {
    name    = "windows-server"
    network = "default"
  
    allow {
      protocol = "tcp"
      ports    = ["3389"]
    }
  
    source_ranges = ["0.0.0.0/0"]
    target_tags   = ["windows-server"]
  }
  
  output "ip" {
    value = "${google_compute_instance.default.network_interface.0.access_config.0.nat_ip}"
  }
  </code></pre>