2
votes

Im new to Stackoverflow. Im a newbie google apps script developer and I wanted to find out if its possible to trigger a powershell script (just a simple helloworld.ps1 file in my local c:\ ) via a google apps script app which I have deployed as web app? If it is possible, can I ask for some tips/steps on how to do it? Thank you very much in advance =)

1
Google Apps Script doesn't run on your browser or your server - it runs on Google's server. So if you want Google to run a script that's on your local machine, your local machine needs to be listening on a publicly available endpoint. Your webapp would then notify that endpoint. - tehhowch

1 Answers

1
votes

You may have to do this the other way around. Use, the Invoke-Webrequest from powershell "poll" the url created by the google apps script.

Here's the google apps script, deploy it as a web app:

function doGet() {
  var output = ContentService.createTextOutput();
  output.append("Hello world!");
  return output;
}

Here's the powershell script:

$webresponse = Invoke-WebRequest "https://script.google.com/macros/s/AKfycbzmYZjft74RLctXjCSrThK3oQr-tpjmNIxtN6Lpwq4fjaKgShaQ/exec"
$content = $webresponse.Content
If ($content -eq "Hello World!"){
    Write-Output "Run Me!"
}

Then have the powershell script run something when the content received is the appropriate value.