如何通过部署为WebApp的Google Apps脚本触发Powershell脚本?

时间:2018-07-25 06:28:02

标签: google-apps-script

我是Stackoverflow的新手。我是一名新手Google Apps脚本开发人员,我想了解是否有可能通过我已部署为Web应用程序的Google Apps脚本应用程序触发Powershell脚本(只是本地c:\中的一个简单helloworld.ps1文件)?如果可以的话,我可以问一些提示/步骤吗?提前非常感谢您=)

1 个答案:

答案 0 :(得分:0)

您可能必须相反执行此操作。使用Powershell中的Invoke-Webrequest来“轮询”由Google Apps脚本创建的网址。

这是google apps脚本,将其部署为网络应用程序:

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

这是powershell脚本:

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

然后,当收到的内容是适当的值时,让powershell脚本运行某些内容。