adnanh / webhook

webhook is a lightweight incoming webhook server to run shell commands
MIT License
10.29k stars 827 forks source link

Issue Launching PowerShell #525

Open Clickbaitcake opened 3 years ago

Clickbaitcake commented 3 years ago

I hope to use WebHook on Windows to kick off some PowerShell and Python scripts to automate processes. I am using Yml config files but running into an unexpected behaviour. Based on the documentation and from what ive seen in other issues my Yml file should look like this:


- id: test
  execute-command: powershell.exe
  command-working-directory: C:\Webhook\Scripts
  pass-arguments-to-command:
  - source: string
    name: WriteLog.ps1

However this config throws the following error message when hooked:

[webhook] 2021/04/01 18:50:01 [30c53a] error in exec: "C:\\Webhook\\Scripts\\powershell.exe": file does not exist

Its as if WebHook is ignoring pass-arguments-to-command and looking for PowerShell inside the command-working-directory which is incorrect.

I modified my config to look like this (removed command-working-directory) hoping to avoid the issue, and it worked.

- id: test
  execute-command: powershell.exe
  pass-arguments-to-command:
  - source: string
    name: C:\\Webhook\\Scripts\\WriteLog.ps1

This does not feel right. From the documentation my first config above should have worked. I have checked that I can run "PowerShell" from RUN and CMD, it launches fine from both so this isnt a %path% issue.

When using pass-arguments-to-command should we omit command-working-directory ? If so, please can the documentation be updated if I make a pull?

moorereason commented 3 years ago

See https://github.com/adnanh/webhook/issues/483#issuecomment-733775846